<FromGitter>
<Blacksmoke16> @drujensen i pushed a fix for the specs on default values
<FromGitter>
<Blacksmoke16> im not sure how specs passed the first time...
<FromGitter>
<drujensen> ok
<FromGitter>
<drujensen> oh, so when I merged, there were conflicting changes. I might have messed up on the merge
<FromGitter>
<Blacksmoke16> ahh no, i know what it was
<FromGitter>
<Blacksmoke16> one of the PRs that got merged in, fixed the PG only specs, which the bug was in that, forgot the `:` on `default`, and was on wrong array field def
<FromGitter>
<Blacksmoke16> so after that was fixed they failed since it wasnt before
<FromGitter>
<drujensen> π
<FromGitter>
<drujensen> @Blacksmoke16 nice work on granite changes. I will release it soon.
<FromGitter>
<eliasjpr> sweet! is it ready for use?
<FromGitter>
<drujensen> So, we were talking about using annotations to automatically build routes and @Blacksmoke16 went and built it
<FromGitter>
<Blacksmoke16> for the most part yes, was waiting on that router release before releasing 0.1.0
<FromGitter>
<drujensen> pretty cool
<FromGitter>
<Blacksmoke16> also does param conversion, so you have access to the actual param as the wanted type, vs having to convert from string all the time, or load a user
<FromGitter>
<eliasjpr> The annotations looks pretty cool
<FromGitter>
<Blacksmoke16> i got basically same setup
<FromGitter>
<eliasjpr> I just noticed, there is no other way I guess
<FromGitter>
<eliasjpr> it does make sense to use a struct instead of a class
<FromGitter>
<Blacksmoke16> not unless you go a big case statement like granite did ha
<FromGitter>
<elorest> @eliasjpr with your shard. β β ```code paste, see link``` β β Is there a reason to have the users specify the setter and initializers for params? Couldn't the macro set that up as well? [https://gitter.im/amberframework/amber?at=5c32cea91d1c2c3f9cd33045]
<FromGitter>
<drujensen> that was my masterpiece. :-D
<FromGitter>
<eliasjpr> I added the converter thing because I am hoping that it can be adopted by any case
<FromGitter>
<eliasjpr> Hey @elorest
<FromGitter>
<elorest> Hey :)
<FromGitter>
<eliasjpr> That was for example purposes
<FromGitter>
<eliasjpr> to demonstrate
<FromGitter>
<elorest> Got it. So basically it just assumes there is an instance var named @params. Like there would be in a controller.
<FromGitter>
<eliasjpr> but behind the scences to wire it with a framework like Amber just need to automatically pass the params to the initializer
<FromGitter>
<eliasjpr> but I was hesistant with this
<FromGitter>
<eliasjpr> the reason for that is that you might have an endpoint (controller action) that received json in the request body
<FromGitter>
<eliasjpr> so you would have to reinitialize
<FromGitter>
<drujensen> I think the repo pattern and crecto would work really well with this since you can just say `Repo.insert(user)` where user is the class or struct created here
<FromGitter>
<eliasjpr> with something like `ExampleController::User.from_json(pyaload: String)`
<FromGitter>
<drujensen> we could have an initializer in Granite that takes a struct
<FromGitter>
<eliasjpr> > Sweet I love it. β Thanks I hope amber can make use of it
<FromGitter>
<eliasjpr> @drujensen one thing I notice that might benefit granite is that it can be initialize with strong types
<FromGitter>
<Blacksmoke16> example?
<FromGitter>
<eliasjpr> for instance definig a schema that matches what granite expects
<FromGitter>
<eliasjpr> not need to take a Hash(String, String) in granite
<FromGitter>
<eliasjpr> in can simple take in a schema
<FromGitter>
<eliasjpr> UserModel.new(UserSchema)
<FromGitter>
<drujensen> right, that might work but we would need to make sure they matched so you are defining it twice
<FromGitter>
<drujensen> once in granite and once in the controller
<FromGitter>
<Blacksmoke16> have a class method on a model to get its schema
<FromGitter>
<Blacksmoke16> which you can build off the properties/fields
<FromGitter>
<eliasjpr> > have a class method on a model to get its schema β β bingo
<FromGitter>
<elorest> @eliasjpr I would think that regardless of the type if we've already parsed params they have a from_json option. So we could probably add something to the schema macro to take custom code. for instance. β β ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5c32d09a5ec8fe5a8513170d]
<FromGitter>
<eliasjpr> but it is reinitializing twice
<FromGitter>
<Blacksmoke16> same idea can be applied for its SQL schema
<FromGitter>
<Blacksmoke16> for a `schema.rb` type thing
<FromGitter>
<eliasjpr> @Blacksmoke16 I like that thought
<FromGitter>
<Blacksmoke16> if its a Granite model it has from_json and from_yaml built in
<FromGitter>
<eliasjpr> got it
<FromGitter>
<Blacksmoke16> since `Granite::Base` includes `JSON::Serializable` and `YAML::Serializable`
<FromGitter>
<eliasjpr> As I was stating to @drujensen to me feels that the model has a lot of responsability
<FromGitter>
<eliasjpr> but again it is MVC, thats why the schema thing might suit better with a REPO pattern
<FromGitter>
<drujensen> yeah, so the idea was to bring the included modules up a level
<FromGitter>
<eliasjpr> you can still use the library to do simply valiations
<FromGitter>
<eliasjpr> it has nice way to define custom validations
<FromGitter>
<eliasjpr> and custom predicates
<FromGitter>
<Blacksmoke16> personally, i just wouldnt be a fan of defining a schema, like that above AND a model with the same properites
<FromGitter>
<eliasjpr> I agree
<FromGitter>
<elorest> @eliasjpr My suggestions above would allow for it to easily work with amber controllers without reinitializing... I'm pretty sure. Do you see an issue with it?
<FromGitter>
<drujensen> me neither
<FromGitter>
<Blacksmoke16> take the annotation route ;)
<FromGitter>
<Blacksmoke16> because i just know you love them, ha
<FromGitter>
<drujensen> lol
<FromGitter>
<Blacksmoke16> in annotation granite would just throw a like `Granite::Column` on there and you good
<FromGitter>
<elorest> Any idea what the the Shardrocks instance on our Digital Ocean account is?
<FromGitter>
<Blacksmoke16> that would handle validations/serialization/orm stuff
<FromGitter>
<eliasjpr> I have to mention that when I see controller I see two other things a Request and a Response, so if I can define with a schema my request input and another schema my response output to me it has a very good construct to reduce any side effecs
<FromGitter>
<Blacksmoke16> depends on how much you want/need to transform the obj
<FromGitter>
<Blacksmoke16> but yea, thats a good way to think about it
<FromGitter>
<eliasjpr> well everything is a transformation in the lifecycle
<FromGitter>
<drujensen> @Blacksmoke16 I think annotations is a really clean way of bringing a modular approach. @eliasjpr and I were discussing that
<FromGitter>
<Blacksmoke16> as you'd want to consume a password on a user for example, but ofc not return that in the response
<FromGitter>
<eliasjpr> @Blacksmoke16 I would have a Response object without it
<FromGitter>
<drujensen> so there are more things than just request/response
<FromGitter>
<drujensen> you could be dealing with a background job or a websocket
<FromGitter>
<drujensen> but I agree that in a controller, your job is to convert a request into a response
<FromGitter>
<eliasjpr> thing of it as SomePasswordService(PasswordRequest, PasswordResponse)
<FromGitter>
<elorest> @eliasjpr @drujensen @faustinoaq Is it ok if I delete the `shardrocks` instance from our DO account?
<FromGitter>
<eliasjpr> @drujensen extactly there is more that happens behind the scene and while I have the request object being pass around to other part of the system
<FromGitter>
<drujensen> we have a DO account? ;-)
<FromGitter>
<eliasjpr> > @eliasjpr @drujensen @faustinoaq Is it ok if I delete the `shardrocks` instance from our DO account? β β I dont know what that is sorry
<FromGitter>
<drujensen> me neither
<FromGitter>
<elorest> Ok. I'm going to delete it then in case I end up having to pay for the account for a couple months until they sponsor us again.
<FromGitter>
<drujensen> So back to the architecture. I like what @Blacksmoke16 is doing with the annotations. We will have the ability to use different patterns like serializers/services/jobs/etc and not be locked in. Right now, granite doensβt allow us to have a separate validator for example
<FromGitter>
<drujensen> its all or nothing
<FromGitter>
<eliasjpr> Fine with me :)
<FromGitter>
<drujensen> what would be cool is the have a POCO and then decorate it
<FromGitter>
<Blacksmoke16> well athena has mine built in atm. IMO there would have to be some higher level spec to determine how each should be implemented for that to work
<FromGitter>
<drujensen> if you add ORM to it, then it will map to a table/column and give you save/delete
<FromGitter>
<drujensen> if you add Serializer, you have the ability to convert to json
<FromGitter>
<drujensen> so granite has a bunch of includes in its base
<FromGitter>
<drujensen> Iβm wondering if we can change granite to be more of a set of tools
<FromGitter>
<drujensen> and you decorate a POCO to get the functionality you want
<FromGitter>
<Blacksmoke16> id be game to strip out some stuff ;p
<FromGitter>
<drujensen> validation, serialization, query, etc would be separate modules you would include
<FromGitter>
<eliasjpr> Im fine either way honestly I think granite was built with a very focused idea and that idea is evolviing
<FromGitter>
<Blacksmoke16> would just need a defined api for how third parties can create other shards to work with it
<FromGitter>
<drujensen> how you do the mapping may be annotations
<FromGitter>
<eliasjpr> the schema validation thing is trying to address the first 2 of that list @drujensen
<FromGitter>
<eliasjpr> and only those two
<FromGitter>
<drujensen> right
<FromGitter>
<Blacksmoke16> imo the way i imagine things is like you have a class with properties, you then annotate those properties; to control things like ORM mappings, validations, serializations, etc. This way all the logic is there and its nothing more than a crystal class (or struct).
<FromGitter>
<drujensen> @Blacksmoke16 yes, that is what iβm proposing
<FromGitter>
<Blacksmoke16> then whatever implementations those things use it doesnt really matter as you're just adding an annotation, not writing custom code for one thing in particular
<FromGitter>
<drujensen> yup
<FromGitter>
<drujensen> so you could remove serialization if you donβt need it
<FromGitter>
<eliasjpr> well
<FromGitter>
<eliasjpr> but validation is domain concern
<FromGitter>
<drujensen> yes, but in an MVC, it would be in the model
<FromGitter>
<drujensen> this would allow you to move that concern where it best fits
<FromGitter>
<Blacksmoke16> fits well with json apis as well
<FromGitter>
<eliasjpr> we are stating the same then
<FromGitter>
<drujensen> yeah
<FromGitter>
<eliasjpr> is just matter of adopting a pattern
<FromGitter>
<drujensen> right, this will allow you to use different patterns
<FromGitter>
<drujensen> repo pattern for example
<FromGitter>
<eliasjpr> now will the annotations will still validate without the wiring?
<FromGitter>
<drujensen> ???
<FromGitter>
<drujensen> you wouldnβt have any mapping without the annotations
<FromGitter>
<eliasjpr> personally I like annotations for 2 things 1 auto generate code and 2 if it has the ability to do assertions as tests
<FromGitter>
<eliasjpr> I see
<FromGitter>
<drujensen> I donβt like annotations at all
<FromGitter>
<drujensen> but this woudl be really powerful
<FromGitter>
<eliasjpr> so if I want to integrate with Granite I can simply annotate a class
<FromGitter>
<drujensen> yes
<FromGitter>
<Blacksmoke16> well not yet
<FromGitter>
<eliasjpr> okay so if I do not want to use granite and my class is already annotated what happends with the logic that lives in the annotations?
<FromGitter>
<Blacksmoke16> that logic lives in the third party shard
<FromGitter>
<eliasjpr> does that do something?
<FromGitter>
<eliasjpr> why 3rd party?
<FromGitter>
<Blacksmoke16> because your app doesnt have anything to do with how granite works
<FromGitter>
<eliasjpr> so thats not different than having any other shard no?
<FromGitter>
<eliasjpr> understood
<FromGitter>
<Blacksmoke16> yes, but the idea would be say you have a class
<FromGitter>
<drujensen> it will still fall under the amberframework
<FromGitter>
<Blacksmoke16> so if you have a `@[Granite::Column]` on a property
<FromGitter>
<drujensen> but you could remove that shard
<FromGitter>
<Blacksmoke16> and you want to change to AbcORM
<FromGitter>
<Blacksmoke16> would just change it to `@[AbcORM::Column]`
<FromGitter>
<Blacksmoke16> (in a perfect world where ORMs have a common pattern)
<FromGitter>
<drujensen> that would be an amazing world
<FromGitter>
<Blacksmoke16> and you not longer have to change/implement specific things
<FromGitter>
<eliasjpr> this only works well in a close ecosystem like .net
<FromGitter>
<drujensen> hhmm
<FromGitter>
<Blacksmoke16> crystal isnt that big, still doable
<FromGitter>
<eliasjpr> where the annotations are standardize
<FromGitter>
<Blacksmoke16> define them now while its early
<FromGitter>
<eliasjpr> the things is that anyone can create their own annotations
<FromGitter>
<drujensen> @eliasjpr that is very true
<FromGitter>
<eliasjpr> is like me saying well I want to annotate Orm columns this way and now anyone who wants to use my orm has to do it my way
<FromGitter>
<eliasjpr> now I think this is the same issue that macros bring to crystal
<FromGitter>
<Blacksmoke16> pretty much
<FromGitter>
<drujensen> its the same issue
<FromGitter>
<Blacksmoke16> but at least then it wouldn't be radically diff
<FromGitter>
<eliasjpr> everyone is defining macros to map orms
<FromGitter>
<drujensen> currently, yes
<FromGitter>
<Blacksmoke16> would still just be a crystal class with annotations
<FromGitter>
<eliasjpr> instead of ussing the crystal way of mapping
<FromGitter>
<eliasjpr> which is JSON.mapping
<FromGitter>
<eliasjpr> should be generalize for orm
<FromGitter>
<drujensen> I had DB.mapping
<FromGitter>
<eliasjpr> as ORM.mapping
<FromGitter>
<drujensen> in granite years ago
<FromGitter>
<eliasjpr> quite honestly I thing that would be best to do
<FromGitter>
<drujensen> moved to using the βfinishedβ macro
<FromGitter>
<eliasjpr> adopt what the language is doing
<FromGitter>
<drujensen> the language has moved over the years
<FromGitter>
<drujensen> and granite has moved with it
<FromGitter>
<eliasjpr> in fact I might now go back and change it to Schema.mapping
<FromGitter>
<drujensen> it was recommended
<FromGitter>
<eliasjpr> and Validations.mapping
<FromGitter>
<drujensen> now the community is moving to annotations
<FromGitter>
<eliasjpr> really?
<FromGitter>
<drujensen> not sure iβm a fan but that is the talk
<FromGitter>
<drujensen> on the crystal channel
<FromGitter>
<eliasjpr> gzz I must been sleeping a lot
<FromGitter>
<Blacksmoke16> JSON.mapping is deprecated yea
<FromGitter>
<eliasjpr> annotations is not good
<FromGitter>
<drujensen> yeah, i agree ;-(
<FromGitter>
<eliasjpr> > JSON.mapping is deprecated yea β β π
<FromGitter>
<eliasjpr> omg
<FromGitter>
<Blacksmoke16> well not super officially
<FromGitter>
<eliasjpr> I use swagger a lot at work
<FromGitter>
<drujensen> @Blacksmoke16 I use swagger at work
<FromGitter>
<drujensen> lol
<FromGitter>
<Blacksmoke16> :3
<FromGitter>
<eliasjpr> you see that is good use of annotation
<FromGitter>
<Blacksmoke16> game i play uses it for their api
<FromGitter>
<eliasjpr> because it will not cause my side effect on my cde
<FromGitter>
<Blacksmoke16> miles better than their old api
<FromGitter>
<drujensen> @eliasjpr if an annotation causes a side affect, you think it shouldnβt be used?
<FromGitter>
<drujensen> Is that your rule of thumb?
<FromGitter>
<Blacksmoke16> anyway, im off to bed. ill catch up tomorrow
<FromGitter>
<drujensen> good night. thanks for all the improvements!
<FromGitter>
<eliasjpr> I am no expert but going back to the scala thing, no annotation affects the output of your code
<FromGitter>
<drujensen> it will work with or without the annotation
<FromGitter>
<eliasjpr> is simply used to enhance the compiler knowlege of the code
<FromGitter>
<eliasjpr> yes
<FromGitter>
<drujensen> right, i think that makes perfect sense
<FromGitter>
<drujensen> using it to do ORM mapping may be an abuse
<FromGitter>
<eliasjpr> In Scala 2.8, you will also be able to use the new @tailrec annotation to get information about which methods are optimised. β This annotation lets you mark specific methods that you hope the compiler will optimise. β You will then get a warning if they are not optimised by the compiler.
<FromGitter>
<drujensen> you should add this to my fib repo
<FromGitter>
<eliasjpr> so everything at compile time not run time
<FromGitter>
<eliasjpr> that last one is about memory allocation lru
<FromGitter>
<drujensen> yup
<FromGitter>
<eliasjpr> you should add it and run the benchmark
<FromGitter>
<eliasjpr> I heading to bed
<FromGitter>
<drujensen> you, ok. good night!
<FromGitter>
<eliasjpr> got to work on scala code tomorrow
<FromGitter>
<eliasjpr> :sad:
<FromGitter>
<drujensen> haha
<FromGitter>
<eliasjpr> i was enjoying crystal a lot over the weekend
<FromGitter>
<eliasjpr> β₯οΈ
<feepbot>
Awwwwwwwwwwwwwww!
<FromGitter>
<eliasjpr> gn
<FromGitter>
<vifreefly> > validation, serialization, query, etc would be separate modules you would include β β Sounds like a good idea! Similar to Sequel plugin system (Ruby's best ORM adapter ever) https://sequel.jeremyevans.net/plugins.html
<FromGitter>
<Blacksmoke16> fix for that is just make sure `Granite.settings.logger` isnt nil before setting that
<FromGitter>
<Blacksmoke16> in the past the logger was defaulted to `Logger.new nil` which would silently swallow everything that was logged to it
<FromGitter>
<Blacksmoke16> because of the colorize stuff, i changed it to be `nil` by default, so the extra logging logic wouldnt run if the user didnt define a logger
<FromGitter>
<Blacksmoke16> i can make a PR to fix that in amber later today if you need
<FromGitter>
<Blacksmoke16> @eliasjpr
<FromGitter>
<eliasjpr> Sweet! If you can get to that cause some PRs are failing because of it
<FromGitter>
<Blacksmoke16> yea can do when i get home tonight
<FromGitter>
<Blacksmoke16> should be pretty easy
<FromGitter>
<eliasjpr> yes
<FromGitter>
<Blacksmoke16> @eliasjpr Managed to do it via Gitub UI