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

IRC log for #mojo, 2017-01-26

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

All times shown according to UTC.

Time Nick Message
00:02 lluad_ joined #mojo
00:11 batman joined #mojo
00:14 lluad_ joined #mojo
00:17 sugar joined #mojo
00:36 mishanti1 The Netherlands welcomes Trump : https://www.youtube.com/watch?v=ELD2AwFN9Nc
01:17 sugar joined #mojo
01:47 tchaves joined #mojo
02:05 stryx` joined #mojo
02:54 marty joined #mojo
03:13 jabberwok joined #mojo
03:22 lluad_ joined #mojo
03:32 disputin joined #mojo
03:45 noganex joined #mojo
04:56 disputin joined #mojo
05:03 lluad_ joined #mojo
05:04 dboehmer_ joined #mojo
05:49 inokenty-w joined #mojo
07:08 dod joined #mojo
07:15 dod joined #mojo
07:24 kiwiroy joined #mojo
07:37 kiwiroy joined #mojo
07:39 Vandal joined #mojo
07:48 Petru joined #mojo
07:50 kiwiroy joined #mojo
07:55 AndrewIsh joined #mojo
08:03 kiwiroy joined #mojo
08:14 kiwiroy joined #mojo
08:21 trone joined #mojo
08:26 kiwiroy joined #mojo
08:38 kiwiroy joined #mojo
08:49 janl joined #mojo
08:51 kiwiroy joined #mojo
09:03 kiwiroy joined #mojo
09:10 celticman joined #mojo
09:15 kiwiroy joined #mojo
09:20 sugar joined #mojo
09:25 sword_smith joined #mojo
09:26 sword_smith_ joined #mojo
09:28 kiwiroy joined #mojo
09:40 sugar joined #mojo
09:48 kiwiroy joined #mojo
10:00 kiwiroy joined #mojo
10:05 sugar joined #mojo
10:11 kes joined #mojo
10:27 kiwiroy joined #mojo
10:40 sugar joined #mojo
11:02 janl_ joined #mojo
11:32 tchaves joined #mojo
11:52 Ryoga joined #mojo
12:10 foursixnine joined #mojo
12:24 castaway joined #mojo
12:24 inokenty joined #mojo
12:26 nic joined #mojo
12:33 sdeseille joined #mojo
12:33 sdeseille hello
12:37 bpmedley joined #mojo
12:38 sdeseille I want to use db handler in mojolicious app. What is the recommanded method to use ? Today i added attribute returning a new db handler each time we call it.
12:39 bpmedley sdeseille : https://github.com/kraih/mojo-pg/blob/master/examples/chat.pl
12:40 bpmedley sdeseille : See how the helper is used with a state variable?
12:43 sdeseille great ! thank you
12:44 sdeseille ok i see the state
12:48 foursixnine joined #mojo
12:50 sdeseille state is something coming with Perl 5.10 ?
12:55 ashimema yup: http://perldoc.perl.org/functions/state.html
12:56 janl I have used state!
12:58 nic It's important to think about the granularity/scope of each db connection
12:58 CHYC Don't you want to get a new db handler every time you call the attribute? Getting the same one gums up the works with non-blocking, amongst other things.
12:58 * sri loves Mojo::DOM so much
12:58 nic A lot of beginners try to make one db connection last forever and forget that the server or network can kill that connection
12:58 sri dealing with xml web services without it would be such a nightmare
12:59 * nic concurs
13:00 * ashimema is always keen listen in on db connection discussions.. especially when they involve some mention of non-blocking.. it's an area he still doesn't feel he has full grip of
13:01 sdeseille I understand
13:01 sdeseille i don't want to open too many connection on database in fact
13:02 sdeseille i'm working on little interface that will be use by few admin
13:03 sdeseille you right when you say i will have to manage network failure and database connection failure
13:05 Petru joined #mojo
13:10 trone joined #mojo
13:25 bobkare A pattern I've used a few times for services with intermittent usage is to have a helper that sets up a db connection and saves it in a state variable if it doesn't have one, and also sets up a timeout to close it on a few seconds of inactivity. It could trivially be expanded to also check that the connection is still live
13:34 sdeseille ok it is interesting
13:47 jberger Mojo::Pg is a connection pool
13:48 ashimema I thought that :)
13:48 jberger You can set the max number of connections too
13:49 jberger sri: agreed on Mojo::DOM
13:49 jberger Using it in a few places at work already
13:50 jberger Used it at the last job too come to think of it
13:52 sdeseille i will use Oracle because it is rdbms at work :(
13:53 jberger I'm sorry
13:53 sdeseille snif
13:57 jabberwok %SYS-U-ENTRAILS: Oracle requires increased offerings for these readings to be deciphered.
13:58 sugar joined #mojo
14:01 sdeseille i'm going to make a sacrifice and hope to be touch by the lord
14:09 gryphon joined #mojo
14:10 [vlad] joined #mojo
14:16 Pyritic joined #mojo
14:21 sdeseille bobkare: have you an example with timeout settings ?
14:24 marty_ joined #mojo
14:26 nic establishing a connection to oracle is still fairly expensive, so usually merits a connection pool
14:27 sugar joined #mojo
14:28 sdeseille where can i start to study that case ?
14:35 bobkare sdeseille: https://0bin.link/paste/vp2mA6Db#JIKB3Z1EQVevh71gGTskkfNZohcyHENxrbotPgLncCs
14:37 sdeseille thanks i'm opening the door of async coding :)
14:43 DavidSouza joined #mojo
14:47 Ryoga joined #mojo
14:51 DavidSouza joined #mojo
14:53 Ryoga joined #mojo
14:56 genio https://www.w3.org/TR/2017/REC-WebCryptoAPI-20170126/ is now a recommendation
15:02 dikim joined #mojo
15:19 foursixnine joined #mojo
15:21 sdeseille if i load value from config file in main package , how can i use that value in a plugin ?
15:21 pink_mist give the value to the plugin when you load it
15:23 sdeseille i call my plugin like that $self->plugin('Heidi::Helpers'); Should i have to add parameters with Plugin name ?
15:24 sdeseille ok i just read the chapter about plugin in doc
15:25 jberger the plugin's register method gets called with the $app as an argument
15:25 orev joined #mojo
15:26 sugar joined #mojo
15:26 sdeseille ho i named that $self in my startup sub
15:26 sdeseille it is the reason you see $self
15:27 pink_mist the name doesn't matter
15:27 pink_mist as long as you know what it represents
15:27 sdeseille i understand.
15:28 sdeseille is it a best practices to named it $app ?
15:29 pink_mist jberger likely used $app when he explained because you'd be expected to understand what he meant
15:29 pink_mist you can use whatever name makes the most sense to you
15:29 sdeseille ok thanks
15:29 pink_mist if he just said it gets called with $self as an argument, you'd have no idea what that $self meant
15:30 sdeseille i see
15:30 jberger yes, we use $app by convention to talk about an instance of the application
15:30 jberger $c for an instance of a controller, etc
15:31 andy_ joined #mojo
15:31 jberger plus, in the plugin's register method the invocant (the first argument) is the plugin instance itself, and the invocant is usually called $self if anything is
15:44 sri btw. did really nobody like my query param route constraint idea?
15:45 pink_mist I did like it, but I've not got a usecase for it myself
15:45 sri get '/foo/api/v1/lalala' => (params => {test => qr/\d+/, bar => ['a', 'b', 'c'], baz => 'yada'})
15:45 sri the use case i had was mock apps in tests
15:47 sri like, in an app i'm testing right now i have mock tests like this https://gist.github.com/anonymous/6072ce53f4c3fe962e45fe9fffc8de15
15:47 sri the same route needs multiple versions with different query param variants
15:48 sri currently i need to give it a closure and check $c->req->url->query->...
15:48 sri and have multiple render calls
15:49 sri get '/public/source/home:kraih/perl-Mojolicious' => (query => {expand => 1}) => {text => <<'EOF'};
15:50 sri that would be the version with ?expand=1
15:50 sri get '/public/source/home:kraih/perl-Mojolicious' => (query => {rev => qr/^\d+$/}) => {text => <<'EOF'};
15:50 sri or one that matches a numeric ?rev=123
15:57 dod joined #mojo
16:11 sugar joined #mojo
16:16 sdeseille left #mojo
16:29 disputin joined #mojo
16:41 disputin joined #mojo
16:43 sugar joined #mojo
16:50 PryMar56 joined #mojo
17:13 sri well, for now i'll add this to my tests https://gist.github.com/anonymous/1626dde7cdcc9f3fc08ee0b17276785d
17:13 sri ¯\_(ツ)_/¯
17:14 disputin joined #mojo
17:15 kgoess if I wanted to launch a dozen $ua->gets in parallel, and wait until I've collected all the results before continuing, is there an idiom for that?
17:15 kgoess or am I thinking about it wrong?
17:15 sri ioloop delays
17:15 Grinnz https://metacpan.org/pod/Mojolicious::Guides::Cookbook#Synchronizing-non-blocking-operations
17:16 howitdo joined #mojo
17:17 sri don't start too many though, better use a queue if it's more than a dozen
17:17 kgoess I'm migrating some old code into mojo, and the $ua->gets are in the middle of the processing--that means I'd have to move all the code that follows the $ua->gets into the second sub{}, right?
17:17 Grinnz yes
17:18 Grinnz otherwise they'd execute before the gets are complete
17:18 sri i actually just wrote and example for a download queue with fixed concurrency https://github.com/openSUSE/desktop-file-translations/blob/master/50-tools/lib/SUSE/DesktopFileDownloader.pm#L66-L84
17:18 kgoess $delay->wait there doesn't actually wait, though, right?
17:19 Grinnz not if you are already in a running event loop
17:19 sri in my cases it does, since the script runs stand-alone
17:20 Petru joined #mojo
17:27 jberger sri: nice, that's more readable than my URLQueue gist
17:27 jberger and re the query mock stuff, I'm not sure that would be quite enough
17:28 sri and it doesn't even use all the pretty features we added in the last few weeks :o
17:28 jberger I usually trap more things that that in my closures
17:29 jberger I was trying to figure out how you could use __SUB__ in that queue
17:29 sri Mojo::File and $tx->result would make it much better
17:29 jberger yeah
17:29 jberger __SUB__ can't work because you need the outermost one
17:29 jberger though I guess it would mean that it wouldn't close over itself
17:31 jberger oh, and mine did need to check the queue size and grow again, because it was a spider
17:31 jberger yours doesn't need that
17:32 * jberger always wants his code to be as clean as sri's, which is why I start looking when mine isn't :D
17:32 Grinnz eek! spiders
17:40 sri i really like Term::ProgressBar
17:40 sri always using it in these kinda scripts now
17:43 sri but i might have mentioned that before ;p
17:47 marty joined #mojo
17:48 lluad joined #mojo
18:04 [vlad] how do i add one Mojo::DOM object to another as a child?  append_content adds it after and append doesn't seem to do anything.
18:05 Grinnz append_content should be the one
18:06 Grinnz are you sure you're calling append_content on the node you want to add it to and not a parent or something?
18:06 [vlad] pretty sure
18:06 purl pretty sure is the case, I did one of the early versions of ->populate and as I recall it was like that
18:06 [vlad] nopaste?
18:06 purl nopaste is http://paste.scsys.co.uk/ or http://gist.github.com/ or DO NOT USE pastebin.com IT FUCKING SUCKS or the command-line interface to App::Nopaste
18:10 bwf Did purl just violate the Code of Conduct? :)
18:10 disputin joined #mojo
18:12 Petru joined #mojo
18:13 [vlad] http://paste.scsys.co.uk/545384
18:13 sri that's the root node
18:13 [vlad] it is
18:13 sri http://mojolicious.org/perldoc/Mojo/DOM#NODES-AND-ELEMENTS
18:14 sri you add content to the root node
18:14 sri not the select element
18:15 sri ->at('select')->add_content(...)
18:15 [vlad] thanks
18:16 sri s/add/append/
18:29 asarch joined #mojo
18:45 jberger bwf: I know you're joking, but swearing isn't on the code of conduct
18:45 jberger targeted at others it could well be, because it could be abuse
18:45 jberger but not in general
18:46 jberger purl: forget pretty sure
18:46 purl jberger: I forgot pretty sure
18:47 Petru joined #mojo
19:00 DavidSouza joined #mojo
19:03 Ryoga joined #mojo
19:39 andy_ joined #mojo
19:42 Ryoga joined #mojo
19:58 tchaves joined #mojo
20:13 coolo sri: the library Net::AMQP used by the rabbitmq client is just bogus :(
20:13 coolo it starts with the header.
20:13 coolo AMQP . pack 1, 1, $MAJOR, MINOR
20:14 coolo but the spec clearly says: AMQP 0, $MAJOR, MINOR, REVISION
20:15 Ryoga joined #mojo
20:18 sri coolo: did you find out yet why it worked before you added tls?
20:21 sri even if Net::AMQP is somewhat broken, pretty much all AMQP clients on cpan depend on it, so i would expect for it to work at least somewhat reasonably well
20:22 sri from what i see in the open issues, perhaps Mojo::RabbitMQ::Client just encoded something wrong
20:23 sri https://rt.cpan.org/Public/Dist/Display.html?Name=Net-AMQP
20:25 coolo sri: there is almost no protocol code in that class - all it does write($stream->raw_frame)
20:26 coolo sri: the packages sent to the amqp:/ look reasonable (beside the header, which seems to be ignored by rabbitmq :) - but the packages sent to amqps:/ are somewhat broken
20:26 coolo wireshark reports unknown method
20:27 sri it's not haproxy trying to rewrite the data?
20:28 sri no wait, you tried other clients
20:29 sri you could test Net::Async::AMQP for comparison
20:30 sri it also supports ssl, and uses Net::AMQP
20:45 tchaves joined #mojo
20:51 DavidSouza joined #mojo
20:54 * coolo struggels to understand the api :(
20:56 Ryoga joined #mojo
20:59 coolo ok, made it work - and it works
21:04 sri good, that means it's fixable :)
21:04 tchaves joined #mojo
21:07 sri both clients share pretty much all of the underlying modules
21:13 orev joined #mojo
21:23 DavidSouza joined #mojo
21:27 coolo sri: yeah. but the 2nd frame already has the wrong length
21:36 Ryoga joined #mojo
22:08 coolo sri: this is really strange. I added debug output to IOLoop::Stream and what is written with syswrite there is not what we get with tcpdump on the server
22:08 coolo but only one byte replaced with 2 others. the rest is fine
22:10 coolo oh no, there is another byte
22:11 * coolo gives up
22:11 sugar joined #mojo
22:13 sri starting to wonder if something about the way we deal with IO::Socket::SSL might have the potential to corrupt the data
22:14 sri would be nice if you could collect the  specific data that gets corrupted
22:14 sri coolo: makes it easier to test
22:22 sri data corruption would be a really serious problem for the whole framework
22:23 kaare_ joined #mojo
22:28 jberger ?
22:29 Ryoga joined #mojo
22:34 sri jberger: coolo is setting up rabbitmq with ssl, and Mojo::RabbitMQ::Client doesn't work anymore
22:34 kaare_ joined #mojo
22:34 sri it's set up with a haproxy for ssl termination, and apparently the data gets corrupted somehow
22:35 sri Net::Async::AMQP seems to work
22:36 kiwiroy joined #mojo
22:37 Petru joined #mojo
22:41 sri hmm
22:41 sri http://perldoc.perl.org/5.8.8/functions/syswrite.html
22:42 sri just noticed the warning at the end
22:42 sri "Note that if the filehandle has been marked as :utf8 , Unicode characters are written instead of bytes..."
22:47 tchaves joined #mojo
22:53 Ryoga joined #mojo
22:55 sugar joined #mojo
23:03 Peppard joined #mojo
23:52 andy_ joined #mojo

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