RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.20.1 | Fund Crystal's development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
soveran has quit [Ping timeout: 268 seconds]
<crystal-gh> [crystal] RX14 opened pull request #3666: Fix file spec when HOME ends with / (master...master) https://git.io/v1ofT
sp4rrow has joined #crystal-lang
sp4rrow has quit [Client Quit]
sp4rrow has joined #crystal-lang
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
sp4rrow has quit [Read error: Connection reset by peer]
sp4rrow has joined #crystal-lang
bjz has joined #crystal-lang
mgarciaisaia has joined #crystal-lang
mgarciaisaia has quit [Client Quit]
Philpax has joined #crystal-lang
Philpax_ has joined #crystal-lang
Philpax has quit [Ping timeout: 248 seconds]
soveran has joined #crystal-lang
pduncan has joined #crystal-lang
soveran has quit [Ping timeout: 250 seconds]
sp4rrow has quit [Quit: The Internet needs a break and I need a cookie]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
ahamon has joined #crystal-lang
ahamon has quit [Ping timeout: 260 seconds]
soveran has joined #crystal-lang
bjz has joined #crystal-lang
soveran has quit [Ping timeout: 258 seconds]
<FromGitter> <andrewhamon> Hey everyone, I'm pretty new to Crystal but I've been hacking away at a project for the last few days
<FromGitter> <andrewhamon> One thing thats starting to *really* bother me is that dependency injection sucks ever since the new type inference algorithm (https://github.com/crystal-lang/crystal/issues/2390)
<FromGitter> <andrewhamon> You can see what I mean here (https://github.com/crystal-lang/crystal/issues/3489#issuecomment-266230444)
<FromGitter> <andrewhamon> So I was wondering if any former rubyists have had similar concerns, and how you worked around it/what other patterns you used instead
<FromGitter> <andrewhamon> I've seen the idea of a `respond_to?` type constraint, which would alleviate basically all of my concerns. Something that looks like `@publisher : respond_to?(:publish)`and would restrict `@publisher` to any object with a `publish` method.
<FromGitter> <andrewhamon> The problem, though, is that I'm pretty sure that in order for that to work at compile time, the compiler would basically have to do all the same work that it would have to do to infer the type of `@publisher`
Raimondi has quit [Quit: WeeChat 1.6-dev]
Raimondi has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 264 seconds]
z64 has quit [Ping timeout: 250 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Raimondi has quit [Ping timeout: 244 seconds]
z64 has joined #crystal-lang
ponga has quit []
<FromGitter> <andrewhamon> So it seems I can use generic classes, with a type parameter for each dependency I want to inject. And then I can instantiate like `Publisher(typeof(hub), typeof(redis)).new(hub, redis)` and everything seems to work fine!
snsei has joined #crystal-lang
Raimondi has joined #crystal-lang
<FromGitter> <andrewhamon> And the friction isn't that bad since DI tends to get used in longer lived objects that I don't instantiate super often
bjz has joined #crystal-lang
<FromGitter> <cjgajard> you can also use inference from arguments of `initialize`, example: https://carc.in/#/r/1fvs
<FromGitter> <andrewhamon> @cjgajard I was literally about to say "But I feel like the compiler should be able to just do what I'm doing"
<FromGitter> <andrewhamon> I'll give that a try, it seems like exactly what I need!
Philpax__ has joined #crystal-lang
Philpax_ has quit [Ping timeout: 258 seconds]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 252 seconds]
<FromGitter> <andrewhamon> Converted all my code, working like a charm!
<FromGitter> <cjgajard> :clap: Is it open source?
<FromGitter> <andrewhamon> Haven't put it on github yet :p But I'm making what's basically a clone of Pusher (https://pusher.com)
<FromGitter> <andrewhamon> I started off with Ruby, but was really put off by EventMachine since it essentially dictates how I do all IO (and its basically required since all the web socket libraries in ruby use event machine in some form)
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
sp4rrow has joined #crystal-lang
matp has quit [Remote host closed the connection]
matp has joined #crystal-lang
sp4rrow has quit [Quit: The Internet needs a break and I need a cookie]
mgarciaisaia has joined #crystal-lang
mgarciaisaia has quit [Client Quit]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
snsei has quit [Remote host closed the connection]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 244 seconds]
Raimondii is now known as Raimondi
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 264 seconds]
Philpax__ has quit [Ping timeout: 248 seconds]
<FromGitter> <sdogruyol> @andrewhamon that's great to hear
<FromGitter> <sdogruyol> when do you plan to release it?
Philpax has joined #crystal-lang
vivus-ignis has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
_whitelogger has joined #crystal-lang
bjz has joined #crystal-lang
fedruantine_ has joined #crystal-lang
fedruantine has quit [Quit: client exited: Ex-Chat]
dhk has joined #crystal-lang
triangles has joined #crystal-lang
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 245 seconds]
rolha has joined #crystal-lang
<rolha> hello everyone
<rolha> can I have an initialize method in an abstract class?
<FromGitter> <sdogruyol> @rolha hello
<FromGitter> <sdogruyol> i guess you can
<rolha> hi sdogruyol
<rolha> ah, ok. It's just that I have a abstract class Foo with a initialize
<rolha> and a class Bar < Foo
<rolha> when I call Bar.new ... the compiler complains Bar has no initialize with that signature
<rolha> might be a mistake of mine then, thanks
<FromGitter> <sdogruyol> @rolha since Bar inherits from the abstract Foo it has to have that method :)
<rolha> sdogruyol, thanks. it must be definitely an error in my code then.
<FromGitter> <cjgajard> lol that's interesting, https://carc.in/#/r/1fvw https://carc.in/#/r/1fvx
<FromGitter> <sdogruyol> why?
<FromGitter> <sdogruyol> you'd need to implement the Int32 also
<rolha> so this is the error I'm getting: https://play.crystal-lang.org/#/r/1fw1
dhk has quit [Quit: Leaving]
<rolha> if Bar has no initialize, this works fine.
<FromGitter> <sdogruyol> i guess overloaind initialize is the problem
<FromGitter> <sdogruyol> overloading*
<rolha> ok, I see. thanks!
<FromGitter> <sdogruyol> @rolha maybe you can open an issue for this on Crystal GH repo
<rolha> will do, thanks
<FromGitter> <sdogruyol> @rolha thank you too
<FromGitter> <cjgajard> rolha, you can do this https://carc.in/#/r/1fw3 :)
<FromGitter> <sdogruyol> wow, that's interesting :D
<rolha> cjgajard, that's will work! thanks
<FromGitter> <sdogruyol> Quite off-topic, What's your editor / ide for Crystal development?
<rolha> I don't know if you're asking me :) but I'm using Sublime Text 3 with the crystal bundle on OS X.
<rolha> sometimes vim when working on ssh
<rolha> the automatic formatting/lint on save is quite useful :)
<FromGitter> <sdogruyol> @rolha i'm also using ST 3 with Crystal bundle it's great :)
<FromGitter> <sdogruyol> i just started a poll on Twitter https://twitter.com/sdogruyol/status/807921705498845185
<FromGitter> <cjgajard> mine = atom + `crystal` package, the linter works great
<FromGitter> <sdogruyol> atom is a cpu killer
<rolha> I used to use atom but this ^^^
<rolha> a text editor shouldn't need 4Gb RAM :-P
<FromGitter> <sdogruyol> indeed
<FromGitter> <sdogruyol> i uninstalled atom when it cant even open a file over 1MB
soveran has quit [Remote host closed the connection]
<FromGitter> <cjgajard> rolha, the code you pasted on my workaround is the same code that fails :sweat_smile:
<rolha> duh. copy pasta malfunction, sry
<rolha> fixed
<FromGitter> <sdogruyol> @rolha i like you scientific blog posts
<FromGitter> <sdogruyol> keep up the great work :)
<rolha> sdogruyol, ahah thanks.
<FromGitter> <sdogruyol> yeah it definitely has different perspective for me
<rolha> sdogruyol, crystal has a lot of potential in that area
<FromGitter> <sdogruyol> it seems like so but i dont get much about math stuff :P
<rolha> python has taken a lot of ground in this area and i think crystal has everything to be better
<rolha> it just needs the mind share
<FromGitter> <cjgajard> rolha, yes, great work on that blog! (but if you allows me to comment something I don't like that all functions arguments have type declarations :( crystal strong point is not having to declare them... IMHO, arguments types should be only for overloading)
<FromGitter> <sdogruyol> probably so but why no Go or Rust?
<rolha> they have potential too of course. it's all down to libraries, community, IMO
<rolha> the typing system is a plus a my opinion
<rolha> one of the problems, again in my opinion, with python
<rolha> is that dynamic typing makes it difficult to make big projects
<FromGitter> <sdogruyol> @rolha dynamic needs a lot of test coverage for big stuff
<FromGitter> <sdogruyol> no compiler to cover your back
<rolha> yes. crystal's compiler saved my bacon many times.
<FromGitter> <sdogruyol> same here
<FromGitter> <sdogruyol> I've seen that we're spoiled by Ruby and most of the time we're doing careless stuff leading to runtime erros with a lot of nils
<rolha> and the error messages... :) really cool. "do you mean resampled instead of resample?"
<FromGitter> <sdogruyol> Ruby is great does a lot of stuff but sometimes we have to do our part :P
<rolha> yep, but it's good to offload some work on the compiler :)
<FromGitter> <sdogruyol> indeed, IMHO it's a win / win
<rolha> i never programmed in ruby before
<rolha> that's why i so many silly questions :-P
<FromGitter> <sdogruyol> @rolha yo should definitely share your experience
<rolha> *have
<FromGitter> <sdogruyol> nope, you ask good questions
<rolha> i will! lunch time, sry. see you all
rolha has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<FromGitter> <sdogruyol> see you
bjz_ has quit [Ping timeout: 252 seconds]
bjz has joined #crystal-lang
Philpax has quit [Ping timeout: 248 seconds]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 265 seconds]
<crystal-gh> [crystal] firejox opened pull request #3671: Improve rehash when collision is high (master...optimize-rehash) https://git.io/v1oEO
rolha has joined #crystal-lang
vivus-ignis has quit [Ping timeout: 248 seconds]
vivus-ignis has joined #crystal-lang
vivus-ignis1 has joined #crystal-lang
vivus-ignis has quit [Ping timeout: 260 seconds]
vivus-ignis1 is now known as vivus-ignis
ponga has joined #crystal-lang
ZackLuvsGamez has joined #crystal-lang
<ZackLuvsGamez> how do i download the language
rolha has quit [Remote host closed the connection]
soveran has joined #crystal-lang
rolha has joined #crystal-lang
soveran has quit [Ping timeout: 258 seconds]
ZackLuvsGamez has quit [Quit: Page closed]
<RX14> i hate it when they leave before you can help them
rolha has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
rolha has joined #crystal-lang
<FromGitter> <sdogruyol> agreed
unshadow has joined #crystal-lang
<unshadow> Hi Guys, started working on libssh bindings in Crystal, if anyone is interested, here it is: https://github.com/bararchy/crystal_ssh
<FromGitter> <sdogruyol> @unshadow good job
<unshadow> :)
<unshadow> Papierkorb: Dont you think passing in a Hash is easier ? and more clear
<Papierkorb> unshadow: It's not easier, and how is it clearer? The caller can just use the arguments via names
<Papierkorb> Now I'd have to either hope you document it, then figure out how you meant the docs, OR I read the code itself and just hope it's not behind garbled if conditions of sorts in there or somewhere else
<Papierkorb> Or, I just use named arguments and it's crystal clear.
<Papierkorb> unshadow: Even Ruby understood it, as there've been named arguments now for quite some time.
<Papierkorb> In crystal, they're named (or unnamed), you can force the caller of the method to use named ones though if you insist
Raimondii has joined #crystal-lang
<unshadow> Papierkorb: Done :) It does looks nicer now
Raimondi has quit [Ping timeout: 244 seconds]
Raimondii is now known as Raimondi
<Papierkorb> unshadow: Happy to help. It was done like this by many in Ruby, and there it created exactly the same issues docs-wise, that's why I really don't like it
soveran has joined #crystal-lang
<FromGitter> <fridgerator> Anyone else using `crystal-pg` with connection pooling (`pool` shard) right now? It seems `crystal-pg` v0.12.0 was released recently which added `crystal-pg` support. I'm having some issues after the update.
<FromGitter> <fridgerator> specifically: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=584d8e21bb7d528222e56a70]
rolha has quit [Quit: Textual IRC Client: www.textualapp.com]
<FromGitter> <sdogruyol> @fridgerator i think the documentation needs to change
<FromGitter> <sdogruyol> it's now crystal-db compatible
<FromGitter> <fridgerator> does crystal-db handle the pooling now?
<FromGitter> <sdogruyol> yeah seems like
<FromGitter> <fridgerator> you're right, the documentation for both crystal-pg and crystal-db is a little confusing
<FromGitter> <sdogruyol> imma check crystal-db with pg
<FromGitter> <sdogruyol> let's see
crystalmq has joined #crystal-lang
<crystalmq> Hey all!
<FromGitter> <fridgerator> hello
<crystalmq> Firstly, thanks so much for all the support with Crystal - we're loving it.
<FromGitter> <sdogruyol> @crystalmq hey
<crystalmq> Secondly, I've got a question about threading.
<crystalmq> We're noticing that if we have two fibers running, but one of the fibers is maxed out, the second doesn't get a look in.
<crystalmq> I can see that concurrency is supported in fibers
<crystalmq> But does anyone know the plans for parallelism?
soveran has quit [Ping timeout: 250 seconds]
<crystalmq> (I could find a few things on the github, etc... but nothing concrete)
<FromGitter> <sdogruyol> @crystalmq parallelism is being worked on
<FromGitter> <sdogruyol> are you blocking the event loop with too much work?
<crystalmq> Yes, exactly
<crystalmq> We find that when we reach ~150k requests per second, our secondary 'spawn' never gets scheduled
<FromGitter> <sdogruyol> makes sense
<crystalmq> Yes, it does make sense :D
<FromGitter> <sdogruyol> you need to fork a process :P
<FromGitter> <sdogruyol> for now Crystal is single-threaded
cococoder has joined #crystal-lang
<crystalmq> Right.
<FromGitter> <sdogruyol> what are you building?
<FromGitter> <sdogruyol> a message queue?
<crystalmq> Basically, as the name suggests a message queue :)
<crystalmq> and it's blindingly fast
cococoder_ has joined #crystal-lang
<FromGitter> <sdogruyol> 150k sounds a lot
<FromGitter> <sdogruyol> you're building a mq from scratch?
<crystalmq> It is :) We're just benchmarking - we don't ever expect to get 150k in real world scenarios
<crystalmq> And yes, funnily enough!
<crystalmq> I built a prototype on a flight
<FromGitter> <sdogruyol> lol on a flight?
<crystalmq> and I'm using it in our testing environment right now, it outperforms nsq
<unshadow> crystalmq: checkout this example: http://hackmyfortress.com/blog/crystal-lang-vs-nodejs-vs-golang-vs-http-benchmark looks at the multi-thread example in Crystal, this is your best bet
<FromGitter> <sdogruyol> i dont know anything about nsq
<crystalmq> Yup ahhaa... it was a 12 hour flight so it's not that impressive
<crystalmq> @unshadow, really appreciate it. Thanks
<FromGitter> <sdogruyol> @crystalmq a blog post about that would be great (not the flight :P)
<crystalmq> When benchmarking redis vs 'crystalmq', were seeing a 10% performance gain over redis.
<unshadow> Nice !
<crystalmq> For sure, we're just working on stabilising it now
<FromGitter> <sdogruyol> that's really amazing
<crystalmq> but you can checkout the github if you like
<unshadow> sure, do share
<crystalmq> Please do note that this was written on a red-eye
<crystalmq> There is a lot to fix, but it is workable
<crystalmq> and it has only been made possible by you guys at crystal...
<unshadow> crystalmq: a README.md is so needed hahah
<FromGitter> <sdogruyol> i've seen this project
<crystalmq> @unshadow
<crystalmq> you are right
<crystalmq> You saw it already? I created the project today!
<FromGitter> <sdogruyol> you should thank @asterite :P
<crystalmq> Small community
<crystalmq> haha
<FromGitter> <sdogruyol> @crystalmq ofc,
<FromGitter> <sdogruyol> no
<FromGitter> <sdogruyol> crystalshards.xyz
<crystalmq> ahhh!
<FromGitter> <sdogruyol> you can see the recent shards e.g
<FromGitter> <sdogruyol> :D
<crystalmq> your indexing is amazing.
<crystalmq> hahaha
cococoder has quit [Ping timeout: 260 seconds]
<FromGitter> <sdogruyol> you can discover any shard from here
<crystalmq> well, I would appreciate constructive criticism... and pull requests even more :)
<FromGitter> <sdogruyol> :D
<Papierkorb> crystalmq: You usually don't add lib/ to the git
<FromGitter> <sdogruyol> i'm a mq noob (just a user)
<crystalmq> @Papierkorb - I'm a total n00b when it comes to crystal so I'll fix that
<Papierkorb> Was a bit confused at first if it contains any project code
<crystalmq> thanks for the tip
<crystalmq> Yeah, actually @cococoder informed me that my directory layout was all wrong
<crystalmq> so he will be fixing it ;)
<FromGitter> <sdogruyol> @crystalmq are you a Rubyist?
<crystalmq> I am, yes. Our production code all runs ruby
<FromGitter> <sdogruyol> great
<crystalmq> I've been saying for years I would love a ruby-esq language that is strongly typed and not interpreted... then i found crystal
<FromGitter> <sdogruyol> yeah, it's a dream come true
<crystal-gh> [crystal] adrien-thierry opened pull request #3672: Create cluster.cr (master...master) https://git.io/v1oi8
<Papierkorb> "Finally one can build shit thats fast"
<RX14> hmm, i'm not sure why having too many requests per second would stop a spawn{}
<crystalmq> @RX14 It seems as though it might be IO bound - because the spawn outputs to a socket
<crystalmq> But my (limited) understanding is that the fibers should yield when they are IO bound
<unshadow> crystalmq: sent you a PR :)
<RX14> yes
<RX14> fibers will yields when read/write blocks
<RX14> then a callback gets added to libevent
<RX14> the scheduler has a queue of fibers to be run
<crystalmq> @unshadow recevied thanks! I'll take a look now
<RX14> and spawn and the like schedule it on the end
<crystalmq> @RX14 Right..
<RX14> every yield pops the top fiber
<RX14> if there's nothing to run it runs the event loop
<RX14> so every fiber should be scheduled
<RX14> if anything was to get starved it would be the event loop
<crystalmq> @RX14 That makes sense
<crystalmq> so the symptoms I'm seeing are this:
<crystalmq> at around 100k requests per second (input on one TCP socket, output on another TCP socket), i can see equal inputs and outputs
<crystalmq> When we read the 180k requests per second mark, i can see the inputs are stable at around 180k, but no outputs (the consumer is showing 0 messages received and no data coming from TCP Socket)
<crystalmq> Eventually, after about 30 seconds the OOM killer kills the app
<crystalmq> so this leads me to believe the inputs are being buffered (as evidenced by the memory balloning)
<RX14> so, what work gets done on every request?
<crystalmq> But for some reason, the fiber with the 'output' isn't getting scheduled time
<RX14> unshadow, that doesn't look like the same symptioms
<crystalmq> @unshadow, doesn't look the same to me unfortunately
<crystalmq> @RX14 the basic premise is that data is received on an input socket, and then is output to N number of clients on their already connected sockets (stored in an array of sockets)
<crystalmq> Does that make sense? It's 1am here and I'm not sure if that makes sense to anyone but me
<FromGitter> <sdogruyol> @fridgerator pg is now working with crystal-db
<unshadow> @sdogruyol how can I get Gitter invite ?
<Papierkorb> ?
<FromGitter> <sdogruyol> just login with your github acc
<RX14> crystalmq, let me have a look at your code
<RX14> yes I saw that i'm just reading it now
<crystalmq> @RX14 :D Thanks
<unshadow> ./quit
unshadow has quit [Quit: leaving]
<FromGitter> <fridgerator> @sdogruyol ⏎ ⏎ ```results = DB.exec(query_string, params) ⏎ results.to_hash``` ⏎ ⏎ that works for you? I get an error [https://gitter.im/crystal-lang/crystal?at=584d946e0da034021b98393c]
<FromGitter> <sdogruyol> that wont work
<FromGitter> <sdogruyol> you need to use crystal-db interface
<FromGitter> <sdogruyol> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=584d94ccb4ffd59e3815471b]
<FromGitter> <fridgerator> ok thanks
soveran has joined #crystal-lang
<RX14> crystalmq, i'm not quite sure of the topology here
<RX14> there's topics and channels
<crystalmq> @RX14, correct. So it looks like this:
<crystalmq> A topic can have many channels
<crystalmq> A channel has many clients (sockets) connected
<crystalmq> When a message is sent to a topic, it will be distributed to only one client (socket) on every channel for that topic
<crystalmq> A client can connect as either a consumer of a topic (i.e a client with a socket) or a producer, which will send a message to a topic.
<crystalmq> (this is copied like-for-like from NSQ)
<RX14> ok
<RX14> thanks
<FromGitter> <sdogruyol> https://github.com/nsqio/nsq just seen it
<FromGitter> <sdogruyol> how's the crystal version compared to go?
<RX14> yeah I got it now
<crystalmq> @sdogruyol looks like the crystal version is faster
hako has joined #crystal-lang
<RX14> well
<RX14> this isn't optimized at all
<crystalmq> @RX14 Totally agree with you there!
<crystalmq> (The worst part is the spawn/loop/spawn/loop)
<RX14> i'm really not sure what the problem is with crystal
<RX14> when it locks up you should run perf on it
<crystalmq> @RX14 - what perf tools would you recommend?
<RX14> you want to build --debug --release
<crystalmq> Ive literally been using crystal about a week :)
<crystalmq> thanks for that.
<crystalmq> I'll give that a go and let you know.
<RX14> then after that
<RX14> you want to use perf record -p pid
<RX14> maybe adjust the sampling frequency with -F
<RX14> that'll produce a perf file
<RX14> which you can then use perf report on
<crystalmq> @RX14 I'll take a look, thanks for all your help everyone.
<RX14> no problem
cococoder_ has quit [Quit: Page closed]
<FromGitter> <bcardiff> @sdogruyol @fridgerator be aware that `#query_all` allocates an array for all the result. Better use `#query` so you can stream one row at a time.
<FromGitter> <sdogruyol> @bcardiff does query also accept the type with as: like queary_all ?
<FromGitter> <bcardiff> `#query` returns a ResultSet. `ResultSet#read` takes *types as argument. So yes.
<FromGitter> <sdogruyol> cool
<FromGitter> <bcardiff> query_all is built on top of query
bmcginty has quit [Ping timeout: 258 seconds]
<FromGitter> <bcardiff> In the following days we will probably focus on docs/guide for DB now that will/crystal-pg has join the party
<FromGitter> <sdogruyol> yeah guess it's pretty much complete for a beta
<FromGitter> <sdogruyol> and there's the pool already built in
bmcginty has joined #crystal-lang
<FromGitter> <bcardiff> yeap. with many options that can be tweaked from the querystring of the connection string
<FromGitter> <sdogruyol> i realized that after taking a look at the source
<FromGitter> <sdogruyol> will there be a more intuitive way for configuration?
<FromGitter> <sdogruyol> like a config object or something
<RX14> I need transactions before switching though
<RX14> I built my own transaction wrapper for the old crystal-pg
soveran has quit [Remote host closed the connection]
<FromGitter> <bcardiff> transactions are done, not released. @RX14 if you want a peek / give feedback https://github.com/crystal-lang/crystal-db/pull/25 is needed for https://github.com/crystal-lang/crystal-db/compare/feature/unprepared...feature/transactions and the update for crystal-pg is ready at https://github.com/will/crystal-pg/compare/master...bcardiff:feature/transactions
<FromGitter> <bcardiff> As for connection option, yes, probably some api more flexible that just a string will come, since we also have https://github.com/crystal-lang/crystal-mysql/issues/14 in the backlog.
<RX14> no nested transactions?
<RX14> that's a blocker for me
<RX14> I run my specs in transactions, and the code which I run uses transactions
<RX14> so it's required
<FromGitter> <bcardiff> not yet. a savepoint factory need to be implemented.
<FromGitter> <bcardiff> @RX14 is your tx wrapper reusable? maybe I can take a look at it.
<RX14> this is what I did
<RX14> i had a counter per connection
<RX14> then named my savepoints using random numbers
<RX14> although I probably could have used the counter
crystalmq has quit [Quit: Page closed]
<FromGitter> <bcardiff> I see. Why random instead of incremental?
<RX14> the savepoint syntax might be pg-specific though
<RX14> because it was just easier at the time
<RX14> random numbers are cheap anyway
<FromGitter> <bcardiff> ok. Something you lack there is a state check. like what happens if the parent tx is rollback/commit and the inner transaction want's to continue doing something?
<RX14> i'm not sure thats even possible
<RX14> because it's savepoints you rollback to a specific place in the transaction
<FromGitter> <bcardiff> if you always use nested block for transaction no, but if you keep object around you might reach that state.
<RX14> they're not true nested transactions
<RX14> well
<FromGitter> <bcardiff> Yes, but you might end in an invalid state from the programmers perspective. Not the main story for sure.
<RX14> actually i don't think it's so much of an issue if you keep the API simple
<RX14> like you begin the transaction and subtransactions the same way
<FromGitter> <bcardiff> But I will see if I can do nested transaction during the week. I didn't though someone was using them already.
<RX14> well I said the code was a hack
<FromGitter> <bcardiff> Yes, that would be the api idea.
<RX14> but it works
<RX14> like you can only push and pop transactions from a stack
<RX14> and then you can't really get to an invalid state
<FromGitter> <bcardiff> only ongoing transactions should be able to exec queries. upon commit/rollback tx the child transaction need to be marked as not-ongoing / closed . Not a big deal I want to provide better exception if possible.
<RX14> well I wouldn't have multiple transaction objects, just keep the transaction state in the connection
<RX14> then you don't have to worry about the bookkeeping
<RX14> you just have 2 operations on connection: begin trasnaction and commit trasnaction
<RX14> and all the bookkeeping is internal without transaction objects flying around
<RX14> oh and rollback transaction obviously
<FromGitter> <bcardiff> I don't want commit/rollback in connections. But let me think about the design for nested transaction. I just avoided until now.
<FromGitter> <bcardiff> i've to go now. thanks for the intereset.
<RX14> byte
<RX14> bye*
<RX14> heh
snsei has joined #crystal-lang
sp4rrow has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Ping timeout: 268 seconds]
pawnbox has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
vivus-ignis has quit [Ping timeout: 265 seconds]
soveran has quit [Remote host closed the connection]
<FromGitter> <sdogruyol> @fridgerator are you going to switch to crystal-db for crecto?
<FromGitter> <bararchy> What is the current "go to" web framework in Crystal ? I know Amethyst is kinda dead
<FromGitter> <sdogruyol> i guess it's kemal @bararchy
<FromGitter> <bararchy> (y)
<FromGitter> <bararchy> cool , thanks :)
<FromGitter> <bararchy> :+1:
<FromGitter> <sdogruyol> :D
<FromGitter> <bararchy> @sdogruyol What do you think about using #3672 for cryload ?
<FromGitter> <sdogruyol> @bararchy havent thought of that :P
<FromGitter> <bararchy> it could exec the cryload bin for each CPU core, I think maybe this way you can gain higher loads
<FromGitter> <bararchy> It could also show us if the Libevent loop is the issue or sockets
<FromGitter> <bararchy> as in Concurrent Connections
pawnbox 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
soveran has quit [Remote host closed the connection]
<FromGitter> <fridgerator> @sdogruyol yes, thats my plan
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
<FromGitter> <sdogruyol> @fridgerator great
soveran has quit [Remote host closed the connection]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
soveran has joined #crystal-lang
snsei has quit [Remote host closed the connection]
bjz has joined #crystal-lang
<crystal-gh> [crystal] dylandrop opened pull request #3673: Fixes #3547; as call with implicit receiver when invoked as a parameter to a method call (master...fix-3547) https://git.io/v1obU
soveran has quit [Remote host closed the connection]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
ssvb has quit [Ping timeout: 265 seconds]
mgarciaisaia has joined #crystal-lang
<FromGitter> <jots_twitter> How to do $x number of `HTTP::Client.get` requests concurrently and return when all have completed? https://play.crystal-lang.org/#/r/1fxu
<Papierkorb> jots_twitter, See `future`
<Papierkorb> Something like: urls.map{|url| future{ HTTP::Client.get(url) }}.map(&.get)
<Papierkorb> That should alreqady do
<Papierkorb> -q
<FromGitter> <jots_twitter> thanks. I will have to read up on futures. first stab didn't work, program exits without printing any data: https://play.crystal-lang.org/#/r/1fy2
<BlaXpirit> firejox, I only now noticed your suggestion "Maybe we can use Pointer.null to get type id". unfortunately, that doesn't work
<BlaXpirit> I suspect that .crystal_type_id just reads the value at the pointer, but that's exactly the problem - we need to set the value ourselves
<BlaXpirit> that gave me a different idea, and this workaround actually works https://carc.in/#/r/1fy8
<BlaXpirit> or realloc could be a different workaround
<BlaXpirit> if that's a thing
<BlaXpirit> seriously though, when you think about it, overriding `allocate` is useless to userspace program, you literally have no way to correctly implement it
<BlaXpirit> (other than silly workarounds)
<BlaXpirit> sigh, even this doesn't save me though, because instance_sizeof(self) doesnt work
<Papierkorb> jots_twitter, you don't need the hash thingy. Working example: https://gist.github.com/Papierkorb/18b4c38fc193f19932e02f302d4aedc3
<FromGitter> <fridgerator> @bcardiff , I'm working to change the adapter in Crecto to use crystal-db. I'm running into issues using `Time?` as a type in `DB.mapping` (`Nil assertion failed (Exception)`). I see in the roadmap in the readme `Time` is not yet supported, but I was curious if there was any workaround.
<Papierkorb> fridgerator, um do Gitter users get highlighted this way or do I need the @?
<FromGitter> <jots_twitter> thanks @Papierkorb! had the hash thing so that data is cached between requests. I will give this one a try.
<FromGitter> <fridgerator> @Papierkorb I see my name as highlighted
<Papierkorb> Thanks fridgerator
snsei has joined #crystal-lang
soveran has joined #crystal-lang
z64 has quit [Ping timeout: 246 seconds]
<BlaXpirit> so the answer is somewhere in between. the '@' is needed to highlight, but you don't necessarily have to type it
snsei has quit [Ping timeout: 260 seconds]
soveran has quit [Ping timeout: 246 seconds]
matp has quit [Remote host closed the connection]
matp has joined #crystal-lang
z64 has joined #crystal-lang
ssvb has joined #crystal-lang
mgarciaisaia has quit [Quit: Leaving.]
sp4rrow has quit [Quit: The Internet needs a break and I need a cookie]