<FromGitter>
<thelinuxlich> does anyone here uses rabbitMQ with Crystal?
<FromGitter>
<thelinuxlich> @watzon I'm using your pool fork, and after half a hour consuming the pool it always throws during pool.checkout: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Do you know what could be causing this? [https://gitter.im/crystal-lang/crystal?at=5eeda1d6fa0c9221fc4c68dc]
<FromGitter>
<didactic-drunk> @dscottboggs_gitlab I find `preview_mt` reliable with carefully chosen dependencies or managing shared data structures myself. Many shards aren't ready.
<raz>
thelinuxlich: haven't used amqp with crystal (don't know if it has shards for it). just as a word of caution; unless you have a legacy system or very specific requirements i'd generally avoid amqp and rather stick with nats, sqs, kafka, redis et al
<raz>
amqp is a collection of footguns and rarely a headache worth having
<FromGitter>
<thelinuxlich> hmmm good advice, gonna test nats them
<oprypin>
jhass, hm probably a bit weird to do log entries based on how they're being passed to the io (could be subject arbitrary splits based on buffer size)
<oprypin>
to*
oddp has joined #crystal-lang
<jhass>
yeah, it's generally weird
<jhass>
how should it behave? buffer everything until close to emit as one entry?
<jhass>
split lines?
<oprypin>
both
<jhass>
idk, it's manveru's idea :P
<FromGitter>
<manveru> lol
<FromGitter>
<manveru> hard to say, but i think linewise is best for terminal apps...
<jhass>
well, you got a PoC there, have fun :P
<FromGitter>
<manveru> i'm trying to spawn some threads that each run another application that has tons of output, and i want to distinguish which output came from where
<FromGitter>
<manveru> yeah :)
<FromGitter>
<manveru> i tried the pipe approach, but there's no way with that
<FromGitter>
<manveru> thanks a lot
<FromGitter>
<manveru> this already behaves perfect for my use, will tweak it if needed later :)
<oprypin>
ok so there's this interesting problem i have on Windows. in Crystal i'm interfacing with another library, through C ABI, of course. to my best knowledge, the bindings I have written are correct, I even did many cross-checks (printf sizeof, etc). I also thought I had implemented the ABI correctly.
<oprypin>
*but* when calling a particular function with a complex signature, everything silently crashes. and I determined that the crash happens after the crystal code has started the call and before entering the function body in C. so it must be messing up the stack. now, how do I diagnose this?
<FromGitter>
<wyhaines> @manveru! It's been a long time. Nice to see that you are exploring Crystal!
<FromGitter>
<manveru> oh hey :)
<FromGitter>
<manveru> yeah, been using it on-and-off for a few years now... but recently getting to use it in more production stuff
<FromGitter>
<manveru> it's pretty neat for our devops stuff, not many runtime errors, and still rather easy to write
<FromGitter>
<wyhaines> Yeah. I'm looking at it right now for some devops-ish stuff. I started diving into it in earnest when the company that I am with now started looking in earnest at using my venerable Analogger package as a seed for a new project. I reimplemented it with Crystal, and then diverged it into the new codebase. It's been an absolute treat to work with, and that fact that unless there's an algorithm error, by the time
<FromGitter>
... it compiles, there are usually few or no runtime errors has me looking at devops stuff where I can apply it.
zorp_ has quit [Ping timeout: 256 seconds]
<FromGitter>
<manveru> well, atm i'm building a replacement for NixOps with it :)
<FromGitter>
<manveru> using Nix to generate terraform and machine configs, and Crystal to make the UX nice
<FromGitter>
<manveru> but also used it for prometheus exporting, wrote a little chaos-monkey replacement for messing with network settings from the browser, making a process supervisor to keep a very unstable app running... and a bunch of other things
<jhass>
oprypin: maybe it's passing for you out of luck?
<jhass>
garbage just happens to return the right result
<FromGitter>
<dscottboggs_gitlab> @didactic-drunk could you offer some advice on how shared data can be managed in Crystal? I'm not sure what caused my issues with `preview_mt` in the past. I'll have to take another crack at it if someone is being successful with it
<jhass>
oprypin: or stuff just happens to retain in the right registers
<FromGitter>
<wyhaines> @manveru Yeah. I don't think Ruby will ever go away in my lexicon., but for a lot of my own personal projects, Crystal has won over my heart.
<oprypin>
did i really just find a bug on x86_64 too
<oprypin>
how did you get that pointer like that? because if i add a temp variable `v = LibFoo::S.new(x: 6, y: 7); LibFoo.foo(1, 2, 3, 4, 5, v)`, the result changes from garbage to just 0
<jhass>
count the reg args, count the sse args, if more than 6 or 8 respectively prior, mark structs as byval
<FromGitter>
<didactic-drunk> @dscottboggs_gitlab For shared data there are many options. I'll list a few: ⏎ ⏎ 1) Treat it like java/c++. Use Mutexes/atomics on everything shared. ⏎ 2) Treat it like go (Channels). Pass your data structures using channels and only mutate them in 1 fiber at a time. ⏎ 3) Treat it like a functional language. Use struct or immutable (https://github.com/lucaong/immutable) data structures with
<FromGitter>
<dscottboggs_gitlab> hm, I feel like I tried with 2 and 3 and only using stdlib but I could've just messed it up or be misremembering. I'll try it again one of these days with your tips in mind
<FromGitter>
<didactic-drunk> Array, Hash, nothing except struct are thread safe.
<FromGitter>
<dscottboggs_gitlab> well that's less than great. what about String?
<FromGitter>
<alexherbo2> hi
<FromGitter>
<dscottboggs_gitlab> guess not
<FromGitter>
<didactic-drunk> Somewhat. As long as you don't `.to_slice` then modify it.
<FromGitter>
<renich_gitlab> If anybody wants to join, you're welcome to. We ain't used to collect a few things scattered around the net about Crystal. Keen seems to help by proposing you articles you can add and stuff.
<FromGitter>
<Blacksmoke16> thoughts on how to test optional shards? Like imagine you have two shards A and B. Shard B can be used with shard A, but it is not required. If it is used, shard A has some extra code to integrate shard B into it.
<FromGitter>
<Blacksmoke16> current plan is to just add shard B as a developmen_dependency and test the integration within shard A
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<oprypin>
Blacksmoke16, yea nothing wrong with that
<FromGitter>
<Blacksmoke16> Cool, I guess it gets trickier when the integration code changes the default behavior, so probably will need to setup isolated tests specific for that
<FromGitter>
<Blacksmoke16> Probably a good usecase for spec tags
<oprypin>
Blacksmoke16, regarding "integration code changes the default behavior" thats just a problem of its own, i think that shouldnt be done??
<FromGitter>
<Blacksmoke16> im not sure how to avoid it tho. A more definite example would be, say you include the `serializer` shard, the renderer would go from using `.to_json` to using the serializer implementation
<FromGitter>
<Blacksmoke16> i suppose they could be separate implementations and the serializer one just runs before the default one, hmm
<oprypin>
explicitly pass some object from serializer shard to it
<FromGitter>
<Blacksmoke16> hm?
<oprypin>
Renderer.new(serializer: Serializer)
<FromGitter>
<Blacksmoke16> hmm, let me try something
<FromGitter>
<Blacksmoke16> yea, probably better to just change what serializer object gets provided to the renderer
<FromGitter>
<Blacksmoke16> use some default implementation by default, when the serializer shard is required, have that define another that is used instead
Jesfre has quit [Ping timeout: 240 seconds]
<FromGitter>
<Blacksmoke16> yea i think i like that better, seems to be working fine
<FromGitter>
<j8r> @ImAHopelessDev_gitlab hello, I am still working from time to time in Godot
<FromGitter>
<j8r> I got a performance issue with drawing polygons in Node2D :(
zorp_ has joined #crystal-lang
oddp has joined #crystal-lang
zorp_ has quit [Ping timeout: 240 seconds]
<FromGitter>
<j8r> I guess I have to touch to GLSL shaders :|
<FromGitter>
<jwoertink> `Process.run("psql -U postgres", shell: true, input: STDIN, output: IO::Memory.new, error: STDERR)`. I have this line of code, but it enters a prompt. To get around this, I'm doing `%(echo "\\q" | psql -U postgres)`.
<FromGitter>
<jwoertink> Is there another way to pass that `"\q"` to this command?
<FromGitter>
<j8r> what is the prompt?
<FromGitter>
<jwoertink> the psql prompt
<FromGitter>
<j8r> I guess that depends also of? the input
<oprypin>
@jwoertink: wait so what's the problem or what do you want to accomplish
<FromGitter>
<jwoertink> I want to test that I can connect to postgres using specific credentials. The best way for what I need that I've found is to just try using `psql`.
<FromGitter>
<jwoertink> But if it works, it enters the psql prompt which just hangs
<FromGitter>
<j8r> that expected
<FromGitter>
<jwoertink> so I need to send the `\q` so it quits
<oprypin>
@jwoertink: stdin: :close then??
<FromGitter>
<jwoertink> oh sweet
<FromGitter>
<jwoertink> yup, that's what I wanted
<FromGitter>
<j8r> Executing `\q` looks ok
<FromGitter>
<jwoertink> thanks oprypin
<FromGitter>
<jwoertink> Yeah, the `\q` was working, but it's wonky
<FromGitter>
<j8r> when do you execute the close then?
<FromGitter>
<jwoertink> I didn't know `input: :close` was a thing 😅
<FromGitter>
<jwoertink> or stdin: :close
<FromGitter>
<j8r> ha
<oprypin>
input is correct
<FromGitter>
<jwoertink> yeah, first one
<FromGitter>
<jwoertink> lol
<FromGitter>
<j8r> not sure it will work
<FromGitter>
<j8r> nvm
<FromGitter>
<j8r> So, essentially it will close client-side instead of the server doing so?
<FromGitter>
<jwoertink> oh... wait... maybe that isn't working.. I fixed one part, but broke another
<FromGitter>
<jwoertink> nope, wrong again
<FromGitter>
<jwoertink> ugh. I need to step away from this computer
<FromGitter>
<jwoertink> 😂
<FromGitter>
<j8r> I think `\q` is good, it tests that an user can use psql and execute command
<FromGitter>
<j8r> I don't understand the wonky part :/ ?
<FromGitter>
<jwoertink> I don't like how this looks `%(echo "\\q" | #{command})`
<FromGitter>
<jwoertink> So I was looking for another way to do it
<oprypin>
jwoertink, as long as you dont do input: STDIN anything can work
<oprypin>
u can pass `input: IO::Memory("\\q")` or sth
<oprypin>
but i'm only guessing because you didnt specify what the problem is no
<oprypin>
w
<FromGitter>
<jwoertink> I like this `input: :close` option. It's pretty clean
<FromGitter>
<j8r> it works?
<FromGitter>
<jwoertink> yeah. Helps when you save the file before running it 😛
<FromGitter>
<rishavs> Is a HTTP:Request immutable? Or can I add more attributes to it? For example, I am thinking of an authenticating middleware which after running will add a `IsAuthenticated = true` to the request
<FromGitter>
<Blacksmoke16> you can do that, its a class so its not immutable
<FromGitter>
<j8r> Possible, but does not mean it is good
<FromGitter>
<Blacksmoke16> wouldnt it be better to do like, if you're *NOT* authorized, return a 401 and just not continue?
<FromGitter>
<watzon> I want to know if and when this is ever going to be possible https://carc.in/#/r/9b0b
<FromGitter>
<watzon> Procs seem to have a hard time working with subclasses
<FromGitter>
<watzon> It's been a problem for as long as I can remember
<oprypin>
watzon, this is expected
<FromGitter>
<watzon> Is there any way around it though? Any possible way to make that workable from a language perspective?
<oprypin>
hm no i'm not so sure.. i mean, it's doable but it's the same reason that Array(HTML) wouldn't pass as Array(Resource)
<FromGitter>
<Blacksmoke16> the workaround is wrap the proc in another proc that casts the value to the inner proc to the type you want
<FromGitter>
<Blacksmoke16> i think i have an example, sec
<FromGitter>
<watzon> So basically create a "Handler" class/struct with a generic?