<FromGitter>
<Blacksmoke16> kinda an offtopic question, but anyone familiar with cmake? I'm trying to build something but getting `CMake Error: No GHS toolsets found in GHS_TOOLSET_ROOT "/usr/ghs/".`. I imagine im missing some package but :shrug:
<FromGitter>
<Blacksmoke16> nvm, some bad config was cached incorrectly
<FromGitter>
<lbarasti> I'd be happy to switch to Alpine, BTW
<FromGitter>
<lbarasti> ah, apologies @Blacksmoke16, I thought you meant going something like `FROM alpine`, but you were probably pointing me to something like `FROM crystal:latest-alpine`. I'll give it a go
<FromGitter>
<Blacksmoke16> like you build with the crystal alpine image, then you do `from alpine` and copy the built static binary into there
<FromGitter>
<Blacksmoke16> of which you might need to do like `apk add --update ca-certificates`
<FromGitter>
<lbarasti> OK, I'll try that, thanks. Will let you know how it goes :)
<postmodern>
without looking at the assembly, does `case i when 0..5` vs `if i >= 0 && i <= 5` branching logic compile down to the same assembly?
<FromGitter>
<Blacksmoke16> a case expands to an `if/elsif` statement iirc
<FromGitter>
<Blacksmoke16> i.e. the former is like
<postmodern>
what's the preferred way of adding class methods from a module? define them within `macro included` block or define a `module ClassMethods` and extend that within a `macro included` block?
<FromGitter>
<naqvis> why not simply `include` or `extend` ?
<postmodern>
because i want the module to also add the class methods, in addition to the instance methods defined within the module
<postmodern>
if i want to override all of the various #[] methods, i'd override #unsafe_fetch, correct?
<FromGitter>
<naqvis> don't think so
<FromGitter>
<naqvis> `[]` methods check the index for bounds, while `unsafe_fetch` method bypasses this check
<FromGitter>
<naqvis> so they aren't the same thing
<postmodern>
gotcha
<hightower2>
jrei: in the crystalizer API, it would be awesome if the ignore: parameter could specify whether to just partially ignore. Currently, it's only a boolean, but in my case it would be useful to say that I want to ignore some fields only during deserialization (because I took care of them in a different way), but do include them when serializing
<FromGitter>
<jrei:matrix.org> it reminds me something, could have a similar issue with ::Serializable in the stdlib
<FromGitter>
<jrei:matrix.org> I don't remember where it is, what's the conclusion
<FromGitter>
<HertzDevil> json has these ⏎ ⏎ ignore_serialize: if true skip this field in serialization (by default false) ⏎ ignore_deserialize: if true skip this field in deserialization (by default false) [https://gitter.im/crystal-lang/crystal?at=605348863b9278255bb93567]
<hightower2>
++
<hightower2>
I might have a patch, will submit soon
<FromGitter>
<Blacksmoke16> postmodern i found the best way to handle that is use two separate modules
<FromGitter>
<Blacksmoke16> of which you could setup an `included` hook on the one to also add the extend on the class module
<FromGitter>
<jrei:matrix.org> @HertzDevil: thanks, I remembered having seen this somewhere!
<postmodern>
Blacksmoke16, ok wasn't sure if there was a preferred way
<FromGitter>
<jrei:matrix.org> hightower2: good! I can do it too if you prefer, it is quite simple
<FromGitter>
<jrei:matrix.org> at least for `ignore_deserialize`
<FromGitter>
<jrei:matrix.org> nvm, simple for `ignore_serialize` too
<hightower2>
I couldn't test because #serialize is currently giving me empty content... need to determine why (could be something related to abstract structs, not sure yet)
<FromGitter>
<jrei:matrix.org> `ann[:ignore_serialize] && ann[:ignore_deserialize]` makes no sense?
<hightower2>
this is if someone uses both of these, instead of just saying ignore: true
<FromGitter>
<jrei:matrix.org> right
<FromGitter>
<jrei:matrix.org> hum no, I mean
<FromGitter>
<jrei:matrix.org> why not `{% unless ann && (ann[:ignore] || ann[:ignore_deserialize]) %}`
<FromGitter>
<jrei:matrix.org> ignore_serialize only matters on serialization, not on deserialization
<hightower2>
hm you're right, based on the class name that's right (as mentioned didn't have a chance to test)
<hightower2>
thanks
<FromGitter>
<jrei:matrix.org> I think I spotted a potentially dangerous behavior in my lib
<FromGitter>
<jrei:matrix.org> if a ivar is ignored and has no defaults, it should raise at compile-time (or at least runtime)
<FromGitter>
<jrei:matrix.org> better doing a PR instead of an issue hightower2 :)
<hightower2>
yeah I took a shortcut just to post it for discussion :-)
<FromGitter>
<jrei:matrix.org> otherwise, good job (don't bother with what I just said, will fix this)
<hightower2>
jrei: how do you solve deserializing based on content length, like if I have a series of fields like : [ 10, ...content of size 10... ] , and I need to read the length (first field), then read the second field?
<hightower2>
(or that is out of scope of crystalizer and I should do this part manually?)
<FromGitter>
<jrei:matrix.org> in this regard, the library is dumb
<FromGitter>
<jrei:matrix.org> each field consume exactly what they need in bytes
<FromGitter>
<jrei:matrix.org> in your case, I'm thinking...
<FromGitter>
<jrei:matrix.org> I'll have a struct wrapping both the first field telling the size, and the remaining bytes
<FromGitter>
<jrei:matrix.org> We'll need to add custom serializer/deserializer for ByteFormat
alexherbo2 has joined #crystal-lang
postmodern has quit [Quit: Leaving]
<FromGitter>
<jrei:matrix.org> straight-shoota: I definitely prefer this implementations :)
<FromGitter>
<jrei:matrix.org> I'd even make it HTTP::Context agnostic
<FromGitter>
<Blacksmoke16> > Does not affect #9660. ⏎ ⏎ :sad: :P
<FromGitter>
<jrei:matrix.org> store some sort of tokens for instance
<straight-shoota>
I mean in the context of http
<FromGitter>
<jrei:matrix.org> yeah... the name of the library is "http-session"
<straight-shoota>
Sure, the storage interface could be used for anything
<straight-shoota>
but the main purpose is HTTP sessions
<straight-shoota>
sessions in other contexts are different to implement
<straight-shoota>
possibly even easier, so you don't even need a shard for that
<FromGitter>
<jrei:matrix.org> indeed. Even a cookie sessions store is simple to do (for simple cases)
<FromGitter>
<jwaldrip:matrix.org> Is @bcardiff
<FromGitter>
<jwaldrip:matrix.org> I have a proposal for a Apple Silicon CI solution
<FromGitter>
<jwaldrip:matrix.org> If we can mirror the github repo to gitlab, I can install a runner on one of our m1 minis so that we can test, build, and ship a crystal binary
<FromGitter>
<jwaldrip:matrix.org> and also report CI status back to github from gitlab ci
<FromGitter>
<jwaldrip:matrix.org> Would the core team be interested in that?
<straight-shoota>
I always like CI on more platforms =)
<straight-shoota>
Adding more CI platforms however is not that great
<straight-shoota>
Could you integrate your runner with Github Actions directly?
<FromGitter>
<jwaldrip:matrix.org> It looks like you can do github actions self hosted runners
<FromGitter>
<jwaldrip:matrix.org> We would be willing to run that as well
<FromGitter>
<jwaldrip:matrix.org> Maybe for a small sponsorship callout of some kind :-)
<FromGitter>
<jwaldrip:matrix.org> Question is does the runner support ARM
<FromGitter>
<jwaldrip:matrix.org> .... hmm looks like not yet
<hightower2>
I should install some sort of a timer on tcp connection to close it if there is no app-level traffic for certain amount of time. Do you suggest I just spawn a timer at fixed interval and check if the byte count has increased since the last time, or?
<FromGitter>
<didactic-drunk> I'm running `shards install` to test a `postinstall` script, but it doesn't run. Is this design or a bug? The shard has no dependencies.
<FromGitter>
<naqvis> so you are running `shards install` in `app A` whose `shard.yml` has `Shard B` listed as dependencies?
<FromGitter>
<naqvis> in other words running a `shards install` on app whose `shard.yml` doesn't have any dependencies will be a noop
<FromGitter>
<didactic-drunk> No, I'm running `shards install` in `lib A` with no dependencies for testing.
<FromGitter>
<naqvis> and you want to run postinstall hook on `lib A`?
<FromGitter>
<didactic-drunk> `postinstall` is builds a c library.
<FromGitter>
<naqvis> for this you should add `lib A` as dependency to different app or lib and run `shards install` there, that will invoke postinstall hook for `lib A` after grabbing its contents
<FromGitter>
<Blacksmoke16> prob a good use case for `path:` based dep
<FromGitter>
<Blacksmoke16> assuming that would trigger it...
<FromGitter>
<naqvis> yeah
<FromGitter>
<naqvis> hook is invoked after package has been retrieved/copy to `lib` folder
<FromGitter>
<didactic-drunk> So I need a 2nd project for development of a crystal library without special steps? Why does it need special steps and not just use `postinstall`? It runs if listed as a dep.
<FromGitter>
<naqvis> `postinstall` as name suggests is used to perform some works after this library is downloaded/copied
<FromGitter>
<didactic-drunk> Then it seems a build` hook is necessary. To me the crystal github action should just work for testing. `shards install` should take care of all the dependencies.
<FromGitter>
<didactic-drunk> To clarify. Building `lib a` is a dependency.
<FromGitter>
<Blacksmoke16> could you do like `postinstall: make` then can just run `make` locally to test?
<FromGitter>
<didactic-drunk> Already done. The library works. Adding the github ci action it fails because the library is never built.
<FromGitter>
<didactic-drunk> It seems this will be a point of pain for as the crystal use grows.
<FromGitter>
<Blacksmoke16> how is that a crystal problem?
<FromGitter>
<Blacksmoke16> if your app requires external non-crystal deps to work, it's not really shard's responsibility to manage that for you
<FromGitter>
<didactic-drunk> `git clone libA`. `shards install`. `crystal spec # ERROR`. There's no standard way to develop the library.
<FromGitter>
<Blacksmoke16> but im pretty sure using `make` to build a program is pretty common so i wouldnt say thats "nonstandard"
<FromGitter>
<Blacksmoke16> as the difference here building a program on its own versus in the context of another with it as a dependency
<FromGitter>
<didactic-drunk> It's an extra step that trips people up. I can't see the harm in running `postinstall` to reduce steps. That's what programming is for correct?
<FromGitter>
<didactic-drunk> But why is there a difference? Why is it harder?
<FromGitter>
<Blacksmoke16> im not sure, thats what the issue will need to determine :)
<FromGitter>
<Blacksmoke16> thinking about it it sounds pretty logical that it should run it for all its deps, then for itself
<FromGitter>
<didactic-drunk> There's only 1 circumstance I'm ok with you asking for harder, but I'll need flowers first.
<FromGitter>
<Blacksmoke16> i guess my only hesitation is it fields kinda weird to do a `shards install` when there arent actually dependencies but :shrug: will see how it goes
<FromGitter>
<Blacksmoke16> feels*
<FromGitter>
<didactic-drunk> Yes, that's why I'm surprised. Today there are 0 deps. Tomorrow? `shards install` seems like the logical place to put it. Otherwise in `foo.cr` `{% `cd #{DIR}/.. && make` %}
<FromGitter>
<Blacksmoke16> 🤔 wouldnt `make` be the more stable api?
<FromGitter>
<Blacksmoke16> i.e. atm it just builds the c deps, in future you add shards, so just make it also do an install
<FromGitter>
<naqvis> my understanding is @didactic-drunk is treating `shards install` as build system, which it isn't.
<FromGitter>
<Blacksmoke16> then `postinstall: make` is only thing you need, and when building from source you also just do `make`
<FromGitter>
<naqvis> shards is a separate crystal dependency manager, not a build system
<FromGitter>
<naqvis> iirc previously there was a discussion on having crystal build system like Rake, but later it was settled on using `make` to perform those external dep builds
<FromGitter>
<didactic-drunk> Fundamental question: why is `postinstall: make` run automatically when listed as a dep but not when used within the shard?
<FromGitter>
<didactic-drunk> I am using `make`. For some reason shards has a `yaml` file where I can list actions to run my app/lib needs. But it only runs them some of the time with no reason given as to why I need to do it manually *some* times, but not others. Why?
<FromGitter>
<naqvis> question you should be asking is "are you really installing the shard" ?
<FromGitter>
<naqvis> as no installation is happening, then how come the post installation hook to happen?
<FromGitter>
<naqvis> you are developing a library, so for it test that it is going to work for end-users you need to perform a test like its user, that is adding as dependency
<FromGitter>
<didactic-drunk> Question I *am* asking. I want to make it easy to have pull requests and ease developer friction. What purpose does making it harder serve?
<FromGitter>
<naqvis> your question is building a library
<FromGitter>
<didactic-drunk> Then I'd like another hook with a better name if `postinstall` won't run.
<FromGitter>
<naqvis> not installing a library
<FromGitter>
<naqvis> for building non-crystal stuff, crystal doesn't offer any build system
<FromGitter>
<naqvis> so you are suggested to use some scripts or Makefile
<FromGitter>
<didactic-drunk> We're talking in circles
<FromGitter>
<didactic-drunk> I AM
<FromGitter>
<naqvis> good, then use that build system to build
<FromGitter>
<didactic-drunk> Now how do iI make the experience seamless to new users?
<FromGitter>
<Blacksmoke16> but he has a point as we talked about earlier. Is there a reason the postinstall hook should not run for the problem you're running the `shards install` in too
<FromGitter>
<Blacksmoke16> program*
<FromGitter>
<naqvis> yes for cloning your library and for users who would use your library as dependency, shards install and posthook will do the work
<FromGitter>
<didactic-drunk> No one has answered my question as to why it should require extra steps. Other than falling back on "it's not a build system".
<FromGitter>
<didactic-drunk> No one has answered why the steps are different when a dep vs development.
<FromGitter>
<Blacksmoke16> pretty sure my answer was, make an issue about it to figure out why that difference exists
<FromGitter>
<didactic-drunk> Bad UX.
<FromGitter>
<didactic-drunk> I'm still writing it. But also responding here.
<FromGitter>
<naqvis> please share the link after you are done, i'll definitely upvote :P
andremedeiros has quit [Read error: Connection reset by peer]
andremedeiros has joined #crystal-lang
<hightower2>
Yes. I mean suggesting make is questionable because there are tens of make alternatives, so if someone uses cmake or something, then definitely the flow is nonstandard.
<hightower2>
Also, even if we agree shards is not a build system, there is `shards build` remember :)
<hightower2>
Btw, some 15 days ago or so I mentioned I replaced some python stuff with crystal to get to processing capacity of 2M/hour. Someone asked what was the previous (python) performance. I found out - it was around 40k/hour per process :-)
<FromGitter>
<jrei:matrix.org> that was me haha
<hightower2>
(hehe awesome, now I'm working on replacing another piece - hence my questions about crystalizer)
<FromGitter>
<jrei:matrix.org> x50 perf - great!
<FromGitter>
<jrei:matrix.org> for field size, I agree
<FromGitter>
<jrei:matrix.org> I thought to have an annotation, then haven't done it because didn't need it for me :)
<FromGitter>
<jrei:matrix.org> but the byte size won't be the maximal, it will be the exact size
<hightower2>
Hm why? For example in the String deserializer, you can still keep searching for @byte_delimiter, but don't search beyond max_size bytes...
<hightower2>
I know what you mean, for most other fields other than string the size is fixed. But in those cases the max_size could just be used as a double-check (or even ignored?)
<FromGitter>
<jrei:matrix.org> ha ok, that's a security
<FromGitter>
<jrei:matrix.org> but I still don't see the purpose compared to check the message size
<FromGitter>
<jrei:matrix.org> of course, it is not exactly the string size, but will prevent malicious/bad messages to fill the memory
<hightower2>
where to check the message size? The protocol I'm working on, for example, has fields of type string, that have a max size of 17 (16 chars + null), but it doesn't specify what the actual size is, the deserializer needs to find that out during read (the null char or 16 chars max, whichever comes first).
<FromGitter>
<jrei:matrix.org> I see, so the issue is more a conformance with the protocol than anything else
<hightower2>
yes, but also ensuring that someone doesn't just try exploiting the handler, or ddosing the machine or whatever (or even just mistakenly sending wrong data)
<FromGitter>
<jrei:matrix.org> yes, but for this case on can check the message size (if you deal with Bytes)
<FromGitter>
<jrei:matrix.org> but if it is a streaming protocol, yes I agree
<hightower2>
right, it's just a stream... must adhere to protocol to be able to read packets from it...
<FromGitter>
<jrei:matrix.org> but we could have a `ByteFormat#max_read_bytes`
<FromGitter>
<jrei:matrix.org> anyway, I agree, we can do it
<hightower2>
Btw, I think that the value of max_size (or some other name), if reached, should raise an exception, to indicate an error. For example, let's say we read a string, 16+1 chars max. If the deserializer reaches the 17th char and the string hasn't ended yet (that is, the 17th char isn't \0), then the only logical action would be to raise, because the protocol has been violated, right?
<hightower2>
(I mean, just returning those 17 chars like it was a valid read would be a mistake)
<hightower2>
(for fixed-size reads where could be another option, just named `size` maybe... but that would be separate from the max_size checks)
<hightower2>
s/where/there/
<FromGitter>
<jrei:matrix.org> yes of course
<FromGitter>
<jrei:matrix.org> I'd just max min_size and max_size, and combine both?
<FromGitter>
<jrei:matrix.org> or maybe is possible to have ranges in annotations
deavmi has quit [Ping timeout: 264 seconds]
deavmi has joined #crystal-lang
andremedeiros has quit [Read error: Connection reset by peer]
andremedeiros has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 260 seconds]
alexherbo2 has joined #crystal-lang
ua_ has quit [Ping timeout: 265 seconds]
ua has joined #crystal-lang
andremedeiros has quit [Read error: Connection reset by peer]
andremedeiros has joined #crystal-lang
teardown has joined #crystal-lang
alexherbo21 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 256 seconds]
alexherbo21 is now known as alexherbo2
sz0 has joined #crystal-lang
deavmi has quit [Ping timeout: 265 seconds]
deavmi has joined #crystal-lang
alexherbo2 has quit [Remote host closed the connection]
_ht has quit [Remote host closed the connection]
zorp has quit [Ping timeout: 265 seconds]
alexherbo2 has joined #crystal-lang
aquijoule__ has joined #crystal-lang
alexherbo2 has quit [Remote host closed the connection]
aquijoule_ has quit [Remote host closed the connection]
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Client Quit]
commavir has quit [Ping timeout: 264 seconds]
commavir has joined #crystal-lang
FromGitter has quit [Remote host closed the connection]
oprypin_ has quit [Quit: Bye]
hendursaga has joined #crystal-lang
oprypin has joined #crystal-lang
FromGitter has joined #crystal-lang
hendursaga has quit [Remote host closed the connection]