The web in a box - a next generation web framework for the Perl programming language

IRC log for #mojo, 2015-02-14

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:01 bwf joined #mojo
00:10 d4rkie joined #mojo
00:29 asarch joined #mojo
00:30 davido__ joined #mojo
00:31 disputin joined #mojo
00:44 sri i actually have this working for postgres pub/sub https://gist.github.com/anonymous/27b14eb13a911950b9c2
00:51 sri not sure if i'll actually add it... but pasting here so it doesn't get lost ;) https://gist.github.com/anonymous/de3f35464265cc2363fb
00:51 sri basically an eventemitter with a postgres backend
00:53 Grinnz looks nice and compact
00:53 sri lots of copypasta from eventemitter though
00:59 Mikey i
00:59 Mikey will definitely use it
01:00 jontaylor joined #mojo
01:06 jberger emit seems like the wrong name
01:06 jberger publish or even notify
01:17 Grinnz huh... my centos6 box just got an  update from libevent 1.4 to 2.0, installing a compat lib for 1.4
01:17 Grinnz is libevent still a thing?
01:18 nicomen as our test suite grows, startup time of Test::Mojo->new starts to matter, any tips in how to re-use a server across tests perhaps?
01:20 tempire That's certainly a lot of pasta
01:40 sri well, this works too https://gist.github.com/anonymous/9d6b6d9f049a8ce12931
01:45 sri with the correct terminology https://gist.github.com/anonymous/16ff3147431450938af6
01:46 sri just "pubsub" is not quite official terminology
01:47 sri which may be a good thing, since it represents a concept on top of notifications
01:51 jontaylor joined #mojo
01:56 tempire I like that usage.
01:56 * tempire would use it
01:57 tempire Actually, come to think of it, I'd probably just subclass eventemitter
01:57 tempire Though I guess I'm not the target.
01:57 sri subclass eventemitter?
01:58 sri the notifications go through postgres
01:58 Grinnz aka, between different servers if you want :P
01:59 sri right, this is inter-server-communication
01:59 tempire doh. on(notification
01:59 tempire Ok, yes, I'd use it.
02:09 asarch joined #mojo
02:13 Adurah joined #mojo
02:18 jontaylor joined #mojo
02:21 sri how i love getting these every time i upload a new minion release :S http://www.cpantesters.org/cpan/report/9b40fda7-6c01-1014-8efb-1ad76a7ce6b9
02:34 sri allright, i guess this is the most minimalistic implementation possible https://gist.github.com/anonymous/bee1317bfd6e6925dbea
02:36 marmez left #mojo
02:37 marmez joined #mojo
02:37 marmez left #mojo
02:53 sri actually i'm not sure how the reconnect logic should work exactly
02:54 sri like, what happens if the reconnect fails
02:54 klapperl_ joined #mojo
03:00 sri anyway
03:00 sri created a branch https://github.com/kraih/mojo-pg/compare/pubsub
03:01 sri if anyone here cares enough, solve the reconnect problem ;p
03:07 noganex joined #mojo
03:18 jontaylor joined #mojo
03:28 sri reconnects need to be handled in a simple and predictable way
03:28 sri big problem is that they happen inside the event loop
03:28 sri so if they fail, the whole pubsub system is lost
04:21 Oleg joined #mojo
04:22 sri changed it again, now it tries to reconnect once, and then gives up until someone calls one of the methods, at which point it tries again
04:22 sri and possibly dies with a user visible error
04:22 sri so the reconnect inside the event loop is non-fatal
05:00 reneeb joined #mojo
05:32 reneeb joined #mojo
05:37 lucs joined #mojo
05:41 lucs left #mojo
05:59 dotandimet joined #mojo
06:02 lucs joined #mojo
06:02 lucs Why do I see something like this in many application scripts:
06:02 lucs use lib join '/', File::Spec->splitdir(dirname(__FILE__)), 'lib';
06:02 lucs instead of simply:
06:02 lucs use lib dirname(__FILE__) . '/lib';
06:02 lucs ?
06:08 lucs (Going to bed, I'll check back when I get up tomorrow.)
06:08 lucs Good night!
06:11 marmez joined #mojo
06:21 skittles_ joined #mojo
06:51 Grinnz lucs, because on windows then you'd end up with a weird path i guess
07:04 Adurah_ joined #mojo
07:12 irq joined #mojo
07:49 Vandal joined #mojo
08:03 davido_lt joined #mojo
08:22 jontaylor joined #mojo
08:24 melo joined #mojo
08:36 stryx` joined #mojo
08:53 sh4 joined #mojo
09:23 jontaylor joined #mojo
09:50 jontaylor joined #mojo
10:01 reneeb joined #mojo
10:14 amon joined #mojo
10:27 reneeb jberger: Statocles currently fails to install. Probably due to an outdated version of git. I will move the matrix to a new server tomorrow...
10:30 dotandimet joined #mojo
10:31 pink_mist Grinnz: it's not so much windows that's the issue -- it handles / as pathseparator just fine ... it's more esoteric things like Mac OS 9 that uses : and can have / as part of a file/dirname :>
10:32 pink_mist I'd expect all modern OSes to handle / without any problem
10:36 dotandimet joined #mojo
10:37 davido__ joined #mojo
10:46 dotandimet joined #mojo
10:51 Oleg joined #mojo
11:09 dotandimet joined #mojo
12:01 csson joined #mojo
12:04 basiliscos joined #mojo
12:24 punter joined #mojo
12:34 jberger preaction does that sound right (re reneeb )
12:42 HtbaaPi joined #mojo
12:55 basiliscos joined #mojo
13:13 jontaylor joined #mojo
13:24 tgt joined #mojo
13:24 Adura joined #mojo
13:30 asarch joined #mojo
13:31 marcusr \o
13:44 basiliscos joined #mojo
13:47 jberger o/
13:54 stryx` joined #mojo
14:00 sh4 joined #mojo
14:15 Oleg joined #mojo
14:17 cpan_mojo XML-Loy 0.36 by Nils Diewald - http://metacpan.org/release/AKRON/XML-Loy-0.36 (depends on Mojolicious)
14:19 * sri still wonders if one automatic reconnect, followed by reconnect attempts on every listen/unlisten/notify call is good enough
14:32 zivester joined #mojo
14:41 lucs I don't get it. I'm always on Unix, but I guess it's this that would make sense to me:  use lib catdir(File::Spec->splitdir(dirname(__FILE__)), 'lib')
14:42 lucs And even then, wouldn't dirname() use the appropriate directory separator on the OS it's used on? (making  catdir(dirname(__FILE__), 'lib')  sufficient)
14:53 sri perhaps i'll release Mojo::Pg::PubSub as experimental
14:57 tgt joined #mojo
14:58 lucs s/sufficient/necessary/
14:59 sri looks like my Devel::Cover results were always different because of HARNESS_OPTIONS=j9
15:00 sri without it, tests take forever, but the result is 91.8% now
15:01 irq_ joined #mojo
15:01 jberger sri: locking on the coverdb?
15:02 Nemix sri: how dependent is Mojo::Pg::PubSub on Pg?
15:02 jberger Nemix: specific
15:02 purl well, specific is good when it's in my favour. :)
15:03 sri Nemix: totally dependent
15:03 jberger botsnack
15:03 purl thanks jberger :)
15:03 Nemix ok
15:03 sri http://www.postgresql.org/docs/9.4/static/sql-notify.html
15:03 jberger Nemix: there are other pubsub solutions available if you are looking for something
15:04 Nemix I am :)
15:04 jberger I suspect that the Pg one will be very useful, but in the meantime, Mojo::Redis2 has a very useful pubsub
15:04 sri actually
15:04 sri how does Mojo::Redist2 handle reconnects?
15:05 * sri pokes batman
15:05 * jberger lights the batsignal
15:06 Nemix I will look at Mojo::Redis2.
15:07 jberger Nemix: https://gist.github.com/jberger/78d7c1649d7acbab6a94
15:08 jberger redis backed chat in under 40 lines
15:08 sri jberger: i might steal some of that for a Mojo::Pg example
15:08 jberger been meaning to blog that one for a while now actually
15:08 jberger sri: be my guest
15:13 Nemix jberger: thanks
15:43 sri was super easy to adapt
15:43 sri and just works with postgres
15:57 sri and added to the branch :)
15:57 sri https://github.com/kraih/mojo-pg/compare/pubsub
15:57 sri jberger++
16:07 jberger \o/
16:08 ryozi joined #mojo
16:10 jberger looks nice
16:11 sri uses absolutely no cpu, it's hilarious how much better postgres is than mongodb at this nosql stuff
16:15 jberger :-P
16:15 sri mojolicious idle cpu usage does seema little high with active websockets though
16:16 sri the os x activity monitor might be updating too slow though
16:16 sri sustained 0.4% cpu use does not look right
16:24 sri nope, just os x activity monitor being a bit too slow
16:29 good_news_everyon joined #mojo
16:29 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/NoVF
16:29 good_news_everyon mojo/master 64bfe27 Sebastian Riedel: reduce idle CPU usage of Mojo::IOLoop slightly
16:29 good_news_everyon left #mojo
16:31 sri that hardcoded timer makes the difference between low idle cpu usage and fast graceful shutdowns ;)
16:33 sri better ideas for handling that problem would be more than welcome
16:34 sri and by ideas, i mean patches :)
16:49 stryx` joined #mojo
16:50 jontaylor joined #mojo
16:58 stryx` joined #mojo
17:01 gryphon joined #mojo
17:05 good_news_everyon joined #mojo
17:05 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/NoSb
17:05 good_news_everyon mojo/master 03a10ea Sebastian Riedel: just keep it the way it used to be
17:05 good_news_everyon left #mojo
17:05 sri with preforking there are cpu usage spikes
17:05 sri caused by the accept_interval
17:06 sri which is basically a recurring timer every 0.025s that check the accept mutex whenever there are active connections
17:28 dotandimet joined #mojo
18:08 sri i guess the latest hipster language is Nim
18:10 jberger does it have a secret?
18:12 sri it compiles to beautiful C apparently
18:14 mst I've filed Nim for "next time I think I want C, I should see how easily I can XSify a Nim module"
18:15 sri seems to be a little bit of a rivalry with Rust https://news.ycombinator.com/item?id=9050114
18:18 dotandimet joined #mojo
18:18 sri those are some impressive DSLs for such a low level language https://github.com/dom96/jester
18:19 Nemix anyway to check in code if a helper exists?  My plan was to call one based on variable name but need to know if it exists first
18:20 Nemix I mwan....based on contents of variable
18:21 sri http://mojolicio.us/perldoc/Mojolicious/Renderer#get_helper
18:23 Nemix ugh...sory about that...thanks
18:33 fhelmber_ joined #mojo
18:36 basiliscos joined #mojo
18:38 tgt joined #mojo
19:14 stryx` joined #mojo
19:28 romel joined #mojo
19:31 tgt joined #mojo
19:35 batman sri: https://github.com/jhthorsen/mojo-redis2/blob/master/lib/Mojo/Redis2.pm#L534
19:35 * batman is too social in the real world lately...
19:36 sri batman: does that reconnect indefinitel?
19:36 sri y
19:36 batman what does that mean?
19:36 purl That boy needs therapy.
19:37 sri do you keep trying forever?
19:38 batman sri: depends on the error. but yes, if the server disconnect me i will reconnect forever
19:38 batman "server KEEPS ON disconnecting"
19:38 sri ah, you stop on an actual error
19:38 sri and how do you report that error?
19:39 sri ah, $err argument in the callback
19:40 sri hmm
19:40 batman in the callbacks $self->$cb($err, undef); or $self->emit(error => $err) if there are no callbacks
19:40 sri don't think that works for me
19:40 sri i can't really differentiate between connection close and error
19:41 batman i only reconnect on connection close. not on connection error.
19:42 sri think my approach with one reconnect attempt is the best i can do for now
19:42 batman i thought your pg $fh would let you know if it's closed or not..?
19:42 sri i don't read from the handle
19:43 sri in fact, i already had to use an ugly hack https://github.com/kraih/mojo-pg/blob/master/lib/Mojo/Pg/Database.pm#L143
19:43 sri notifications are a pull api https://github.com/kraih/mojo-pg/blob/master/lib/Mojo/Pg/Database.pm#L120
19:43 sri and behavior on failure is pretty much undefined
19:44 sri https://metacpan.org/pod/DBD::Pg#pg_notifies
19:46 sri i watch if something happens on the file descriptor, and if it does try to call $dbh->pg_notifies
19:46 sri which dies on a closed connection
19:47 sri (i don't think many people use that part of the api)
19:50 sri although, i suppose i could emit an error event on reconnect failure
19:53 sri thanks batman!
19:53 batman sure.
19:53 batman i'm really confused that i could actually be helpful :-)
19:54 batman i'm not even sure how good my solution is, hehe
19:54 sri https://tonegauge.files.wordpress.com/2013/04/tonegauge-confused-batman.jpg
19:54 batman :D
19:55 stryx` joined #mojo
19:57 sri it's a very different solution to yours, but you got me there https://github.com/kraih/mojo-pg/commit/53bb612e116bc1eab51c4cd85cd1edff491e3e82
19:57 sri emitting an error event is not perfect, but a good interim solution, not much to go wrong there
20:00 batman cool :)
20:00 sri (although, i might try without an error event first, just to see how it works out ;p)
20:01 sri Mojo::Pg pub/sub is very different from Mojo::Redis2 pub/sub
20:02 sri i use one dedicated connection shared by everyone, and redispatch arriving messages
20:03 sri it's like an eventemitter, people just add their callback and it calls them on arriving messages (while managing the subscriptions to the different channels)
20:09 batman i wouldn't say that's different. it depends on how you use Mojo::Redis2
20:09 batman but i see your point.
20:10 sri i have to keep the number of connections low
20:10 batman yeah
20:16 * sri wonders if many of our users tweak accept_interval
20:17 sri when you have idle connections in a prefork worker CPU usage is always around 1% with the default
20:18 sri which is 0.025s
20:18 sri with a value of 0.5s it's barely noticeable
20:19 sri but performance drops quite a bit
20:19 sri (slower accepts)
20:21 sri of course i might be the only one who cares :)
20:22 sri if there's any load on the worker from actual work that 1% dimishes... it's mostly just the event loop spinning idle trying to grab the accept mutex
20:23 hasan joined #mojo
20:23 hasan sri: how can I get the Mojo::Pg results as simple json?
20:23 hasan I have to work with Mojo::Collection it seems. but there is no function to return all rows as jsons like it is possible in DBD::Pg
20:24 Grinnz you mean as hashes?
20:24 hasan Grinnz: yes ->hashes gives me Mojo::Collection Objects as HASHes
20:24 Grinnz ->hashes->to_array
20:24 juikuen joined #mojo
20:24 hasan but I'm looking for something like $dbh->sth->fetchall_hashref('id') in DBD::Pg
20:25 hasan ah nice.
20:25 hasan thank you that worked.
20:25 Grinnz fetchall_hashref is different, that would be a hash of hashes
20:26 Grinnz i dont think there is an automatic way to get a structure like that
20:30 mst and it's generally a terrible idea anyway
20:31 mst fetchall_arrayref({ Slice => {} }) is strictly superior IMO
20:36 Grinnz yeah, i rarely use selectall_hashref but there are some cases where it saves some typing (if collisions aren't an issue)
20:36 Grinnz it would be better if you could specify some kind of slice where each value is only one column, but i havent figured out a way to do that
20:37 Grinnz i.e. the selectcol_arrayref functionality
20:39 Grinnz i've commonly had to do this pattern: get a bunch of rows and then put them into a hash with each key => value being one pair of id and some other column
21:13 marmez joined #mojo
21:33 cpan_mojo MojoX-Mysql 0.11 by Kostya Ten - http://metacpan.org/release/KOSTYA/MojoX-Mysql-0.11
21:41 punter joined #mojo
21:41 punter Happy valentine's day
21:42 mst BEEEEEEEEEEEEEEEEEEEEEEEES AND PESTILENCE
21:57 sri tempire: https://twitter.com/genehack/status/566105709364801536

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary