<asterite>
foca: https://github.com/mosop/stdio (though I'd prefer to pass an IO to the program instead of hardcoding STDOUT in it)
<asterite>
p0nce: linux, mac
mbarbar has quit [Ping timeout: 240 seconds]
soveran has quit [Remote host closed the connection]
elia has quit [Quit: Computer has gone to sleep.]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
paulcsmith_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
paulcsmith_ has joined #crystal-lang
Philpax has quit [Ping timeout: 252 seconds]
pawnbox_ has joined #crystal-lang
pawnbox has quit [Ping timeout: 258 seconds]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 276 seconds]
buggs has quit [Ping timeout: 264 seconds]
snsei has quit [Remote host closed the connection]
trapped has quit [Read error: Connection reset by peer]
Oliphaunte has quit [Remote host closed the connection]
zodiak has joined #crystal-lang
zodiak_ has quit [Ping timeout: 252 seconds]
elia has joined #crystal-lang
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 250 seconds]
soveran has joined #crystal-lang
<maxpowa>
hi all, im trying to pass stdin to a process and it doesn't appear to be working... can anyone tell me what im doing wrong? neither of these two work https://carc.in/#/r/13h4
elia has quit [Quit: Computer has gone to sleep.]
<adam12>
maxpowa: Not sure I have an answer for you as I banged my head on this a bit myself
<adam12>
maxpowa: but I'll show you what I used which worked.
<RX14>
what you probbaly want is to use process.new, keep the process handle around and write to it
<maxpowa>
im already past it
<RX14>
how did you solve it
<maxpowa>
the way adam pointed out
<RX14>
well
<RX14>
do you need to write to the process twice?
<maxpowa>
yes
<RX14>
yeah i guess that works depending on your code
Oliphaunte has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
pawnbox_ has quit [Read error: Connection reset by peer]
pawnbox has joined #crystal-lang
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
<wmoxam>
asterite: thx!
soveran has quit [Remote host closed the connection]
Cal has joined #crystal-lang
Cal is now known as Guest72415
<Guest72415>
Hello
<FromGitter>
<sdogruyol> hey
<Guest72415>
Love Kemal!!
<FromGitter>
<sdogruyol> thank you :)
pawnbox has quit [Remote host closed the connection]
triangles has joined #crystal-lang
soveran has joined #crystal-lang
sebler has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
<paulcsmith_>
I tried Kemal a bit and liked it. I'm curious if anyone has used it in prod?
<FromGitter>
<sdogruyol> of course
<FromGitter>
<sdogruyol> sidekiq.cr, rainforest, protel, bulutfon e.g uses it in production
<paulcsmith_>
Ah. I didn't realize that. I figured with crystal still being in the very early phases that people would be hesitant to use it
<FromGitter>
<sdogruyol> btw Protel is where i work and we've been using it in production for more than 6 months it's been great
<paulcsmith_>
Cool to see it being used by a few people
<FromGitter>
<sdogruyol> well not people, actually companies :P
<paulcsmith_>
Oh that's cool!
<FromGitter>
<sdogruyol> and yeah we're making money with Kemal lol
<paulcsmith_>
That's the real test lol
<FromGitter>
<sdogruyol> yeah it's really great, we tend to replace heavy load APIs with Kemal
<paulcsmith_>
What (if anything) are you using for hitting the db?
<FromGitter>
<sdogruyol> and works like a charm
<paulcsmith_>
Yeah it seems blazing fast from the benchmarks I've run
<FromGitter>
<sdogruyol> yeah one of our services are hitting the db quite hard
<paulcsmith_>
"hitting the db" = querying, inserting, etc. I saw crystal-pg, but that's pretty low-level
<FromGitter>
<sdogruyol> like fetching 5k of rows in a single call
<FromGitter>
<sdogruyol> still it's less than 100 ms for Kemal yet Chrome takes shit loads of time to render :P
<paulcsmith_>
Haha yeah I bet
<FromGitter>
<sdogruyol> well crystal-pg is good enough
<FromGitter>
<sdogruyol> you dont have to have ORM for building something
<RX14>
crystal-pg is nice
<RX14>
i prefer not using an ORM
<FromGitter>
<sdogruyol> same here
<RX14>
it means I can actually use pg
<RX14>
with mysql it's not as much of an issue
<RX14>
because frankly mysql doesn't have as much to offer
<FromGitter>
<sdogruyol> who uses mysql anyway :P
<RX14>
uhh
<RX14>
more than half of the internet :P
<RX14>
but yeah
<FromGitter>
<sdogruyol> haha more than %80 uses PHP
<FromGitter>
<sdogruyol> :/
<RX14>
hahahah... hah
<paulcsmith_>
Yeah I'll have to try out crystal-pg then. I've just played around a bit for now. Haven't done anything remotely interesting yet :)
elia has joined #crystal-lang
<FromGitter>
<sdogruyol> it doesnt justify that both are shitty :P
<paulcsmith_>
I do like ORMs, but I'm fine starting with crystal-pg and wrapping stuff myself for now
<RX14>
i'm in the process of procrastinating rewriting a formum from php to crystal
<RX14>
so that should be fun
<FromGitter>
<sdogruyol> well for example we use AWS RDS for PG and crystal-pg for connecting and since it's pure Crystal you dont have to install any c binding
<FromGitter>
<sdogruyol> and it's quite fast
<RX14>
well, if you really want an ORM, ActiveRecord.cr exists
<RX14>
and actively maintained
<FromGitter>
<sdogruyol> and dropping to raw sql with CTE e.g makes me not want to use ORMs
<paulcsmith_>
Oh cool I'll check out ActiveRecord.cr
Oliphaunte has quit [Remote host closed the connection]
<FromGitter>
<sdogruyol> yeah we use pooling
<RX14>
if i'm honest I don't mind an ORM for updates
<paulcsmith_>
Yeah I assumed so. It looked nice. It looks very clean and nice
<RX14>
as long as i can do all reads with SQL
<FromGitter>
<sdogruyol> we use like 25 connections for pooling
<FromGitter>
<sdogruyol> pretty enough
soveran has quit [Remote host closed the connection]
<paulcsmith_>
Yeah that's usually plenty. Very cool. Thanks for the tips :)
<FromGitter>
<sdogruyol> once you compile it you're good to go :)
<FromGitter>
<sdogruyol> and recently someone is building a virtual file system for packing up all the assets into single binary https://github.com/schovi/baked_file_system
<FromGitter>
<sdogruyol> it's pretty cool
<RX14>
luckilly the templates are always compiled in
<RX14>
so it's just assets
<FromGitter>
<sdogruyol> ah yeah
<paulcsmith_>
Wow so you could just deploy a single binary?
<FromGitter>
<sdogruyol> practically yes
<FromGitter>
<sdogruyol> well the binary size gets bigger though :P
<RX14>
paulcsmith_, if you serve assets from a different domain, yes
<RX14>
if you serve assets from crystal you need to bake them or keep the dir
<FromGitter>
<sdogruyol> yeah bake them :)
<paulcsmith_>
Ah that makes sense
<paulcsmith_>
bcardiff I'll check that out :)
<FromGitter>
<sdogruyol> @bcardiff i wish it supported Postgres :(
<RX14>
@sdogruyol, i remember watching one of your talks about kemal where you said the templates weren't baked in and I wanted to correct you haha
<FromGitter>
<bcardiff> it's almost there the pg support ;-)
<FromGitter>
<sdogruyol> RX14 oh sorry to hear that probably a mistake :(
<RX14>
well I personally don't see the point in cross-driver SQL apis because writing sql that supports all engines is basically impossible
<FromGitter>
<sdogruyol> @bcardiff wow that'd be awesome
<FromGitter>
<sdogruyol> well a common api for CRUD is possible imho
<FromGitter>
<sdogruyol> Go is doing that SQL package and i think it's quite nice
<FromGitter>
<bcardiff> but there are many things that can be reused along SQL db. Transaction, connection pooling, preparing statements, etc.
<FromGitter>
<sdogruyol> indeed
<RX14>
yeah
<FromGitter>
<bcardiff> crystal-db does not aim to do any further than that. it won't touch SQL queries. But there are some languague artificats that repeating them on all drivers will be kind of dissapointing.
<RX14>
well yeah i guess
<RX14>
it's useful for implementing
<FromGitter>
<sdogruyol> well at least it'll be much more beginner friendly
<RX14>
trying to write a nested transactions wrapper for crystall-pg is a pain
<FromGitter>
<sdogruyol> RX14 is it? i havent tried playing with transactions yet
<RX14>
well
<RX14>
you have to store the transcation status per-connection
<RX14>
and it gets a bit iffy
<paulcsmith_>
I was about to ask about transactions in crystal-pg :P Sounds tricky
<RX14>
the current method is diy with exec("BEGIN") and COMMIT/ROLLBACK
<paulcsmith_>
Makes sense :) Thanks
<FromGitter>
<sdogruyol> well it's just SQL, don't be afraid :) You have much more control and power than any other ORM out there :P
<paulcsmith_>
Haha true!!
<RX14>
yeah i need my 3-line optimised queries tyvm
<paulcsmith_>
I've actually wanted to do some more "low" level stuff lately. I think I will eventually want to use or write some abstractions over this stuff, but it would be fun to do that myself
<FromGitter>
<bcardiff> I don't know about connection pooling in crystal-pg, but if a transaction is started be sure to not release the connection in between
<FromGitter>
<sdogruyol> that's a tricky one
<RX14>
yeah connection pooling is a seperate shard in crystal-pg
<FromGitter>
<sdogruyol> yeah
<RX14>
the pooling shard is really nice btw
<paulcsmith_>
I love that packages are called "shards." Sounds so cool
<RX14>
you get a connection per fiber
<RX14>
or can check out as many as you want
<FromGitter>
<sdogruyol> yeah i dont think you can interrupt a fiber from another unless you try too hard.
<FromGitter>
<bcardiff> @paulcsmith_ just implement the low level stuff you love in crystal at it will be a nice story. either binary protocols as http, mysql, smtp, ... or compression / checksum algorithm. It's a nice language to build low level stuff in an efficient and comfortable way
<RX14>
the thing is when you check out multiple db connections per fiber, then transactions get difficult
<paulcsmith_>
If a fiber crashes will the "pool" shard check the connection back in?
<paulcsmith_>
Or do you need to make sure you rescue it and check it back in yourself?
<RX14>
well
<FromGitter>
<sdogruyol> nice question
<FromGitter>
<sdogruyol> currently it does not, does it?
<RX14>
if you use the block-style
<RX14>
the exception will trip finally
<RX14>
which will check it in
<paulcsmith_>
Ah that makes sense
<RX14>
if you use the checkout/checkin you have to implement finally yourself
<paulcsmith_>
Thanks :)
<RX14>
you can even create http middleware to do it
<paulcsmith_>
bcardiff yeah it looks pretty nice for low and high level stuff. Speed + beauty. Very appealing. Plus type checked!
<RX14>
yeah, i've pretty much stopped using anything but crystal at this point
<paulcsmith_>
Haha I do that for myself, so I can find it later
<FromGitter>
<sdogruyol> well like rx14 said creating a http middleware is so easily
<paulcsmith_>
But it also make people happy so that's a plus
<FromGitter>
<sdogruyol> well i really like DIY part of Kemal without gazilions of stuff that you dont need (looking at you Rails :P)
<FromGitter>
<sdogruyol> Rails pays the bills though haha
<RX14>
@sdogruyol maybe you should add some sort of checking to see if there is any fonnections checked out to the current fiber after calling call_next and release them?
<FromGitter>
<sdogruyol> yeah i should definitely do something like that (PRs welcome :P)
<adam12>
@sdogruyol: I didn't see it in the docs - is there a way to run Kemal similar to Sinatra in modular form?
<FromGitter>
<sdogruyol> no, not yet
pawnbox has joined #crystal-lang
<FromGitter>
<sdogruyol> that'd be interesting though
<RX14>
i've had bad experiences with sinatra modular
<FromGitter>
<sdogruyol> mperham (creator of sidekiq) also wanted something like that but still i'm hesitant about it because i normally dont embed applications into single process
<adam12>
I was just curious if there was a way to spin up a Kemal server from another app that provided a CLI
<FromGitter>
<sdogruyol> well you can do that
<FromGitter>
<sdogruyol> just require Kemal and run it whenever you want
<FromGitter>
<sdogruyol> you can use spawn to achieve that without blocking if you want
<RX14>
i much prefer using crouter than kemal for big applications
<FromGitter>
<sdogruyol> what do you use for routing algorithm?
<adam12>
So you spawn and inside there, define your route blocks and Kemal.run?
<FromGitter>
<sdogruyol> just Kemal.run inside spawn
<adam12>
No route definitions? Hmm
<RX14>
@sdogruyol it's just a seraching from the tail
<FromGitter>
<sdogruyol> no
<FromGitter>
<sdogruyol> you can define your routes anywhere you want
<FromGitter>
<sdogruyol> but you have to call Kemal.run somewhere , right?
<FromGitter>
<sdogruyol> RX14 sorry for my question, but isnt that kind of redundant
<RX14>
ok
<RX14>
what it does
<RX14>
is it parses the path, and finds the prefix, before any params
pawnbox has quit [Ping timeout: 276 seconds]
<RX14>
and then matches that, longest first
<FromGitter>
<sdogruyol> i see
<RX14>
once it has that, there could be a number of routes that much
<FromGitter>
<sdogruyol> now i'm curious how that compares to radix
<RX14>
which it uses regex for
<RX14>
very badly, i'm sure
soveran has joined #crystal-lang
<FromGitter>
<sdogruyol> not necessarily
Oliphaunte has joined #crystal-lang
<RX14>
how does kemal do route params etc?
<FromGitter>
<sdogruyol> the router uses radix algorithm to match
<FromGitter>
<sdogruyol> named parameters are parsed on the match
<paulcsmith_>
RX14 you said "maybe you should add some sort of checking to see if there is any fonnections checked out to the current fiber after calling call_next and release them?" how would you do that? Can you store state in the Fiber, so you could do `Fiber.current.connection`?
<paulcsmith_>
Or is there some other way that you would handle that
<FromGitter>
<sdogruyol> and all the others are lazily parsed
<RX14>
paulcsmith_, you can create a hash of Fiber to anything
<FromGitter>
<sdogruyol> body, json, query e.g
<RX14>
@sdogruyol, it would be nice if you extracted kemal's routing core into a usabile library so I could use it with the MVC pattern
<FromGitter>
<sdogruyol> paulcsmith_ you can create thread local storage for a fiber but it's kinda hacky for now (as far as i know)
<FromGitter>
<sdogruyol> oh it's a different shard already