Raimondi has quit [Remote host closed the connection]
Raimondi has joined #crystal-lang
Ven has quit [Ping timeout: 240 seconds]
Ven has joined #crystal-lang
jhass has quit [Ping timeout: 245 seconds]
Ven has quit [Read error: Connection reset by peer]
asterite has quit [Ping timeout: 256 seconds]
Ven has joined #crystal-lang
asterite has joined #crystal-lang
Ven has quit [Ping timeout: 258 seconds]
jhass has joined #crystal-lang
Ven has joined #crystal-lang
onvsop has joined #crystal-lang
Ven has quit [Ping timeout: 252 seconds]
Ven has joined #crystal-lang
pawnbox_ has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Ven has quit [Ping timeout: 260 seconds]
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 260 seconds]
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 245 seconds]
Raimondi has quit [Ping timeout: 252 seconds]
Raimondii has joined #crystal-lang
Ven has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Raimondii is now known as Raimondi
triangles has joined #crystal-lang
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 258 seconds]
_whitelogger has joined #crystal-lang
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 260 seconds]
Ven has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
Raimondi has quit [Ping timeout: 252 seconds]
Ven has quit [Ping timeout: 255 seconds]
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 255 seconds]
snsei has joined #crystal-lang
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 245 seconds]
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 248 seconds]
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 248 seconds]
<FromGitter>
<samueleaton> with crystal-db (pg) I can open and close connections as I please, and the connections go back into a pool of connections, right? It wouldn't be bad practice to "open" a connection in each of my app's routes because it is actually just using an existing connection from a pool?
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 255 seconds]
onvsop has quit [Read error: Connection reset by peer]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
bjz has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<FromGitter>
<sdogruyol> @samueleaton you mean using DB.open every time?
kellabyte has quit [Ping timeout: 255 seconds]
bjmllr has quit [Ping timeout: 255 seconds]
aemadrid has quit [Ping timeout: 255 seconds]
hmans has quit [Ping timeout: 255 seconds]
aemadrid has joined #crystal-lang
kellabyte has joined #crystal-lang
bjmllr has joined #crystal-lang
hmans has joined #crystal-lang
triangles2 has joined #crystal-lang
triangles has quit [Ping timeout: 255 seconds]
mark_66 has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 240 seconds]
Kug3lis has joined #crystal-lang
bjz has joined #crystal-lang
bjz_ has quit [Ping timeout: 260 seconds]
Yxhuvud has quit [Read error: Connection reset by peer]
Yxhuvud has joined #crystal-lang
<crystal-gh>
[crystal] firejox opened pull request #3882: disallow other type inherit from String (master...forbid-string-inherited) https://git.io/vM2lj
<FromGitter>
<bcardiff> @samueleaton DB.open creates a connection pool. That's right. You can open one pool for the whole process and per route handler request a connection or even use the Database object directly if you don't need to use *exactly* the same connection per command.
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter>
<samueleaton> @bcardiff ideally I'd want one pool for the whole app but I don't see a clear way to checkout/checkin connections to and from the pool. I was originally thinking DB.open would just checkout a connection from a pool but you confirmed that its creating a new pool.
<FromGitter>
<bcardiff> @samueleaton #using_connection is probably what you want or #transaction http://crystal-lang.github.io/crystal-db/api/0.3.3/DB/Database.html#transaction%28%26block%29-instance-method to be run in each route, again *if you want to checkout explicit a connection*. The only scenario I could think of is a transaction.
<FromGitter>
<bcardiff> @samueleaton why you want to checkout out connections explicitly?
<FromGitter>
<samueleaton> I just wanted to be able to do something as simple as DB.open for each route and know that it was pooling all of my connections. So if I were to do DB.open once in my app and then every time I do db.query it will automatically checkout/in connections?
<FromGitter>
<samueleaton> @bcardiff I guess what might be confusing me is why DB.open takes a block that opens and closes a pool. Wouldn't opening and closing pools be expensive?
snsei has joined #crystal-lang
<FromGitter>
<bcardiff> DB.open has a yielding and non yielding version. It could be time consuming if the initial pool size is more than one.
<FromGitter>
<bcardiff> having a pool with connections ready is better for attending request actually.
<crystal-gh>
[crystal] asterite closed pull request #3882: disallow other type inherit from String (master...forbid-string-inherited) https://git.io/vM2lj
<FromGitter>
<bcardiff> and yes, when you db.exec / query a connection from the pool is checked out. if non is available a new will be built, unless the max is reached. in that case you will be delayed for a bit. if none come available an exception will raise.
<FromGitter>
<samueleaton> @bcardiff now that I have your ear... I was having a problem last night where my specs would just stop at a rs.read(String) for minutes without ever continuing. No errors or anything. I put a "puts" statement before and after it to verify that it would just halt (it never runs the second puts). I'll look more into it today and try to find a simple way to reproduce my problem.
<FromGitter>
<samueleaton> Any preliminary advice on how to debug?
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<bcardiff> for pg / mysql the read will consume the socket. Maybe you are calling read more times that the amount of columns ... but I would expect some protocol exception to raise in that case.
<FromGitter>
<bcardiff> since the socket could be open and on hold for receiving more data you could be experiencing that freeze ...
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
<FromGitter>
<samueleaton> @bcardiff Its the first read() of the block. And before that rs.read I am able to do rs.column_name(0) so I know there is data. Also if I inspect the rs It is *HUGE*. Its caching all of my "delete from" queries that I run in `before_each` for all of my specs.
<FromGitter>
<spalladino> @samueleaton could you share some of your code, if it's public? How are you invoking the `delete`s, by the way?
<FromGitter>
<bcardiff> result_set -> connection -> cache of prepared statements. yes it is huge.
<FromGitter>
<bcardiff> I was going to ask for the same. show me code :-)
<FromGitter>
<samueleaton> its not public but I'll throw something together sometime this morning. Should I take this into a PM or open an issue for us to continue the discussion?
<RX14>
github down for anyone else?
<FromGitter>
<samueleaton> yes. unicorn
<RX14>
same
<FromGitter>
<Sija> @RX14 yep, same here
<FromGitter>
<bcardiff> Ok (╯°□°)╯︵ ┻━┻ lunch time
<FromGitter>
<paulcsmith> I'm getting a strange error when trying to create an HTTP::Handler. Any idea why it says this? https://play.crystal-lang.org/#/r/1k95
<RX14>
at least I opened all my GH notification tabs at the same time
<RX14>
so I have a few remaining github tabs
<FromGitter>
<paulcsmith> `Error in line 3: HTTP::Handler is not a class, it's a module` But in the docs and the crystal source, it is an abstract class
<RX14>
@paulcsmith where does it say that in the docs?
<RX14>
and if the sources say that, you're not looking at the latest release
<FromGitter>
<samueleaton> I like to change the `0.20.4`, `0.20.1`, etc in the path of the api to just be master all the time so I always see the latest docs. e.g. `/api/master`
hako_ has joined #crystal-lang
hako has quit [Read error: Connection reset by peer]
Kug3lis_ has joined #crystal-lang
Kug3lis has quit [Ping timeout: 258 seconds]
Kug3lis_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Kug3lis has joined #crystal-lang
nomethoderror has joined #crystal-lang
nomethoderror has quit [Client Quit]
mhib has joined #crystal-lang
DeBot has quit [Remote host closed the connection]
mhib has quit [Client Quit]
DeBot has joined #crystal-lang
<FromGitter>
<bcardiff> @samueleaton /api/latest/** is rewriten with the lastest tag :-)
Cyrus has quit [Quit: Leaving]
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Kug3lis has joined #crystal-lang
Kug3lis has quit [Ping timeout: 240 seconds]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
Cyrus has joined #crystal-lang
<FromGitter>
<Sija> @bcardiff IIRC there’s no published docs for `master` branch?
<FromGitter>
<paulcsmith> Will do :D Not quite ready yet, but hopefully in a few weeks!
<crystal-gh>
[crystal] david50407 opened pull request #3889: Not to expend default new for non-class (master...no_default_new_in_module) https://git.io/vMaDo
<literal>
so, I can't use abstract class names in type definitions?
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<RX14>
literal, can you show me the bug?
<RX14>
well, code
<literal>
instance variable '@foo' of Bar must be Baz, not Baz::Quux <-- when assigning an instance of Baz::Quux to @foo
<RX14>
can I have the code you're suing too please
<literal>
one moment
<literal>
uh, yeah, misspelled a class name, sorry about that :)
<FromGitter>
<samueleaton> @bcardiff @spalladino About my problem was earlier. I was doing something like: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ I am still confused why it just hung there though instead of giving me an error. [https://gitter.im/crystal-lang/crystal?at=587941d4cbcb28177067e244]
<FromGitter>
<spalladino> Which adapter (mysql, postgres or sqlite)?
<FromGitter>
<samueleaton> PG. BTW my query is returning several columns (but a single row). I am simplifying here in my examples.
<FromGitter>
<spalladino> Hmm aren't you missing to wrap the `rs.read` in a `rs.each` in order to advance to the first row?
<FromGitter>
<samueleaton> Exactly. But i would expect it to complain.
<FromGitter>
<spalladino> If you do add it, it works?
<FromGitter>
<samueleaton> Let me try it. one sec
<FromGitter>
<spalladino> Even if it works, please open an issue in crystal-db explaining the situation; if making that check does not incur in a performance penalty, I'd consider adding it to raise an exception rather than just hanging on the socket
<FromGitter>
<samueleaton> yes. That fixes it. Will open an issue.
<FromGitter>
<aeosynth> how do i create a json mapping when the source is a hash with unknown keys, but the values have known structure?
<BlaXpirit>
aeosynth, maybe don't create a json mapping..?
<FromGitter>
<aeosynth> @BlaXpirit sure, but it would be nicer to declare my type in one place, instead of casting everything inline
<BlaXpirit>
aeosynth, well you could do this inefficient thing.. define json mappings for your kinds of values, then parse the json, do whatever logic and use `SomeType.from_json(parsed[key].to_json)`
<FromGitter>
<spalladino> It will basically attempt with all types in the union catching all parse exceptions until it finds a match
<FromGitter>
<jwoertink> How do you handle a property that can't be nil, but also doesn't have a default value? Is there a way to tell the compiler that I want to throw an error if the property isn't assigned?
<FromGitter>
<jwoertink> or is it better to just make the type a union, and catch the error if it's nil?
<FromGitter>
<spalladino> @jwoertink are we still talking about json mapping, or you mean in general?
<FromGitter>
<spalladino> Yep, in that case, the compiler will complain if it finds a case where x does not get initialized
<FromGitter>
<spalladino> Since you have just one constructor and it always sets x, it should be ok
<FromGitter>
<spalladino> (by the way, `def initialize(@x); end` is a shorthand, though not exactly the same)
<FromGitter>
<jwoertink> In this case, is it better to just make `property x : String | Nil`, then catch for nil?
<BlaXpirit>
jwoertink, no, why make a runtime error when you can make a compile time error?
<FromGitter>
<spalladino> I'd say no, if `x` should always be set, then leave `x` as String, and the compiler will let you know if you attempt to assign `nil` to it at any point
<FromGitter>
<jwoertink> Ah... ok, I see what I'm doing wrong here
<FromGitter>
<jwoertink> actually.. maybe not lol
<FromGitter>
<jwoertink> I need my example to be a little more detailed
<FromGitter>
<jwoertink> ^ this is complaining about the @x being nilable since it's not initialized
<BlaXpirit>
jwoertink, yes, initialization works only if you write @x =
<BlaXpirit>
self.x = is roundtripping through a method and doesn't count as initialization
<BlaXpirit>
because compiler doesnt want to look through what methods may or may not do, it's inefficient
<FromGitter>
<jwoertink> ah! that's what it was
<FromGitter>
<jwoertink> that makes sense. Thanks!
<BlaXpirit>
additionally, if you're looking to create a constructor based on another constructor, it's usually best to write like this: `def self.new; self.new("A"); end`
<BlaXpirit>
because, again, you're going through an `initialize` method and it probably won't work