by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 26 14:02
    Blacksmoke16 edited #34
  • Aug 21 13:11

    github-actions[bot] on gh-pages

    Deploying to gh-pages from mast… (compare)

  • Aug 21 13:09
    Blacksmoke16 commented #9
  • Aug 21 13:09

    Blacksmoke16 on master

    Support ASR::Name strategies on… (compare)

  • Aug 21 13:09
    Blacksmoke16 closed #9
  • Aug 21 13:09
    Blacksmoke16 edited #9
  • Aug 21 08:51
    repomaa synchronize #9
  • Aug 20 18:14
    repomaa edited #9
  • Aug 20 18:13
    repomaa opened #9
  • Aug 13 01:03

    github-actions[bot] on gh-pages

    Deploying to gh-pages from mast… (compare)

  • Aug 13 01:01

    Blacksmoke16 on set-response-content

    (compare)

  • Aug 13 01:01

    Blacksmoke16 on master

    Add action result setter to the… (compare)

  • Aug 13 01:01
    Blacksmoke16 closed #73
  • Aug 13 01:00
    Blacksmoke16 opened #73
  • Aug 13 00:59

    Blacksmoke16 on set-response-content

    Add action result setter to the… (compare)

  • Jul 30 01:34

    github-actions[bot] on gh-pages

    Deploying to gh-pages from mast… (compare)

  • Jul 30 01:33

    Blacksmoke16 on action-event

    (compare)

  • Jul 30 01:33

    Blacksmoke16 on master

    Add a new `Action` event (#72) … (compare)

  • Jul 30 01:33
    Blacksmoke16 closed #72
  • Jul 30 01:29
    Blacksmoke16 edited #72
Kirk Haines
@wyhaines
But I was doing it with a converter originally. Hopefully this morning I finish fighting my way through some of the learning curve because I'm demoing the app in 48 hours and, well, there's a lot of React left to write. :D
George Dietrich
@Blacksmoke16
:grimacing: good luck
ill be around if you need any help/things explained or something
Kirk Haines
@wyhaines
And Bam! Authenticated API request works.
George Dietrich
@Blacksmoke16
\o/
Kirk Haines
@wyhaines
Thank you. If I run into anything else that throws me, I'll ask. Time to go write some pretty dashboard widgets!
George Dietrich
@Blacksmoke16
sounds like a plan
George Dietrich
@Blacksmoke16
get everything working @wyhaines ?
Kirk Haines
@wyhaines
It's working just fine. I am pretty happy with it.
George Dietrich
@Blacksmoke16
:tada: good to hear
Kirk Haines
@wyhaines
I had a product demo today. The CEO was a bit surprised that the entire product is written with Crystal (and React). He's a Ruby guy turned Golang guy, so he'd probably love Crystal if the company were to let him write code. :D
George Dietrich
@Blacksmoke16
went well then i take it?
Kirk Haines
@wyhaines
Yep. Can't argue with the kind of speed that Crystal delivers, and the API memory footprint right now with Athena, under low utilization, is stable at about 10mb.
George Dietrich
@Blacksmoke16
:clap:
Kirk Haines
@wyhaines
BTW, within a couple of weeks I'll have more solid feedback for you on things like performance and RAM usage, but right now, with steady usage since last week, my test instance of the app is still running < 10mb resident set size. So far, it's just completely solid and just sits there doing its job.
George Dietrich
@Blacksmoke16
:tada: good to hear!
George Dietrich
@Blacksmoke16
given most people come from Ruby/Rails land I assume it's also pretty cool converting people from that style of thinking, like @dscottboggs_gitlab recently has i hear
Kirk Haines
@wyhaines
Yeah. I mean, I started Ruby before Rails was a thing, and have never been a huge fan, even though I've earned a living off of it and it's ecosystem for a lot of years. But it's just so heavy. And sometimes that heaviness is exactly what is needed because there is so much stuff that is all designed to work together in the larger framework, but a lot of the time you just want to handle some API calls quickly and easily and all of that weight just gets in the way.
Kirk Haines
@wyhaines

FWIW, running on my WIndows 10 laptop under WSL1, a simple heartbeat controller action: Requests/sec: 18232.2745

That was with a concurrency of 50, over a million requests.

George Dietrich
@Blacksmoke16
not too shabby, single threaded i assume?
Kirk Haines
@wyhaines
Athena? Yeah. Just the default 0.35.1 single threaded mode.
George Dietrich
@Blacksmoke16
:rocket:
George Dietrich
@Blacksmoke16
any suggestions or feature requests now that its done?
Kirk Haines
@wyhaines

It's still a WIP. Right now there is only one thing jumping to the forefront of my mind is that the POST request param handling is a little clumsy -- it's a little ugly to have to parse the request body explicitly to extract the params instead of just having them readily available.

The other thing that will help is to just have copious documentation written as if idiots are reading it. :)

image.png

That's all Crystal/Athena powered through the entire stack below the browser.

Mostly now I am just writing React to make interaction nice, and writing pieces of API to deliver the data.

George Dietrich
@Blacksmoke16

POST request param handling is a little clumsy

You mean like form data?

Kirk Haines
@wyhaines
    @[ART::Post("/api/v1/telemetry/get")]
    def get_data(request : HTTP::Request) : ART::Response
      raise ART::Exceptions::BadRequest.new "Missing request body." unless body = request.body

      data = JSON.parse(body.gets_to_end)
George Dietrich
@Blacksmoke16
:thinking:, why not just use a param converter and JSON::Serializable structs or something?
  @[ART::Post(path: "")]
  @[ART::View(status: :created)]
  @[ART::ParamConverter("article", converter: Blog::Converters::RequestBody, model: Blog::Models::Article)]
  def new_article(article : Blog::Models::Article) : Blog::Models::Article
    article.save
    article
  end
Something like this is what i did for the blog tutorial
Kirk Haines
@wyhaines
So, some set of complex parameters for the API request is being passed in the request body.
George Dietrich
@Blacksmoke16
thats not known beforehand to allow using JSON::Serializable?
Kirk Haines
@wyhaines
OK, so it would require a converter for each discrete collection of parameters, yes?
I can see the thinking here.
George Dietrich
@Blacksmoke16
no, you can reuse the same converter for multiple types
notice in the example there is a model: named argument in the annotation that specifies what type it should try to deserialize the data into
Kirk Haines
@wyhaines
nod So if I have serializeable classes for the data, whether or not it's actually a db backed model, I can plug and play. OK. That will let me do a little cleanup of the code.
George Dietrich
@Blacksmoke16
yea id take a look at the blog tutorial example, and that section in the blog post as well
the example also leverage some serializer component logic that sources the actual obj from the db, then applies the new properties
so like timestamps and such dont really need to be provided since you're not making a new obj
Kirk Haines
@wyhaines

In a lot of my cases, there is nothing directly applicable from the DB. It's a set of params being provided by the UI that lets the API find the right data, but the params and the data being returned don't have any direct relationship.

So in the screenshot example, there is a set of criteria from a panel unseen to the left that lets one select the type of data, date ranges, amount of data, etc... Those are all bundled into a set of params to feed to the API . The API goes and finds information for the requested server(s), of the requested type and timeframe.

There is no correspondence between the params and specific database models, and I'm not returning serialized class model data in the response, either. Rather, it's a minimized, trimmed subset of that data.

George Dietrich
@Blacksmoke16
hmm gotcha
in that case you could also make use of inheritance/reopening. Like define some helper method
def get_data(request : HTTP::Request) : JSON::Any
  raise ART::Exceptions::BadRequest.new "Missing request body." unless body = request.body

  JSON.parse body
end
otherwise im not sure how i could/would provide the data w/o the user manually parsing it, or using a converter
George Dietrich
@Blacksmoke16
o/ @maxbertinetti, good to see a new face in here :wink:
Massimiliano Bertinetti
@maxbertinetti
Hi @Blacksmoke16 , I only changed handle on GitHub.
Massimiliano Bertinetti
@maxbertinetti
I'm @acciaiodigitale on the forum.
George Dietrich
@Blacksmoke16
ah gotcha :thumbsup:
George Dietrich
@Blacksmoke16
good stuff @wyhaines, listened to the podcast