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

IRC log for #mojo, 2017-12-30

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

All times shown according to UTC.

Time Nick Message
00:12 zivester joined #mojo
00:20 CandyAngel OKay.. can't find in my logs where I've discussed this before..
00:21 CandyAngel In templates, if I want some helper to span multiple lines.. I have to use the interpolated version (<%=), right?
00:58 tchaves joined #mojo
01:35 bit_shifter joined #mojo
02:03 jamesaxl joined #mojo
02:12 Leffe joined #mojo
02:14 preaction no, you can do <% ... %>
02:19 marty joined #mojo
02:21 jberger wk glad you liked it!
02:22 jberger To be said to be inspiring is one of the best compliments I could get
02:35 CandyAngel preaction: yeah, that's what I meant :)
02:35 preaction sorry, then yes
02:36 preaction the = is the bit that makes it interpolate
02:36 CandyAngel Sorry, using the wrong terminology >.<
02:36 CandyAngel <% ... %> is.. inline?
02:37 preaction that works, yeah
02:37 preaction or block. block also works
02:37 CandyAngel CSS makes me sad
02:38 preaction it shouldn't
02:38 CandyAngel I set one table cell to be vertical-align: top
02:38 CandyAngel Every cell following it also does (where it should be baseline)
02:38 CandyAngel This is what I want.. but.. what
02:38 CandyAngel (using reset.css)
03:03 FROGGS joined #mojo
03:13 rmallah joined #mojo
03:49 karjala_ joined #mojo
04:04 rmallah joined #mojo
04:05 bit_shifter What's the best way to efficiently use keep-alive connections, from the client side, without having to wait for timeouts at the end of all the non-blocking calls?
04:06 bit_shifter You can obviously set the inactivity_timeout to a low value, but it doesn't seem ideal.
04:07 bit_shifter max_connections(0) also works... but it doesn't reuse the keep-alive connections, right?
04:17 mohawk CandyAngel, http://2.bp.blogspot.com/-41v6n3Vaf5s/UeRN_XJ0keI/AAAAAAAAN2Y/YxIHhddGiaw/s1600/css.gif
05:00 Leffe joined #mojo
05:04 dboehmer_ joined #mojo
06:08 Leffe joined #mojo
06:33 geospeck joined #mojo
06:40 mohawk TIL that passing a promise to this: $c->render(json => $data);
06:41 mohawk stringifies the promise into 'Mojo::Promise=HASH(blah)'
06:41 mohawk it would be a nice feature if renderers took promises and self-then-ed them?
06:44 mohawk in the graphql-js codebase, such a thing is referred to as "apply-lift"
06:48 mohawk sri, what do you think of the above?
06:50 mohawk also: the Promise->all doc is a bit overly concise: it doesn't spell out that because ->resolve can take a list, then ->all "then" necessarily gets passed is promise's result as an array-ref of each promise's fulfilled result
06:51 mohawk (is each promise's result)
06:52 mohawk at the moment, the needed knowledge is only available by reading t/mojo/promise.t
07:04 Vandal joined #mojo
07:10 bianca joined #mojo
07:23 geospeck joined #mojo
07:33 Leffe joined #mojo
07:39 mohawk also, JS Promise.all can take non-promises and will treat them as fulfilled. Currently Mojo::Promise->all('hi', $other_promise) will throw: Can't locate object method "_clone" via package "hi"
07:39 mohawk if you would like a PR on these topics, let me know
07:40 mohawk my JS sample code FYI: Promise.all(['hi', Promise.resolve('yo')]).then(d => console.log(d))
07:41 mohawk (a PR, or >1, or whatever you prefer)
07:42 mohawk and my perl repro code: perl -MMojo::Promise -e 'Mojo::Promise->all("hi")'
07:50 mohawk sri, additionally, looking at the code: i would question why ->all is an instance method at all. i recognise that might be just your choice, like with "resolve"
07:50 mohawk seems like i can proceed if i have my wrapper code do Mojo::Promise->new->all(@_)
07:56 mohawk i think the "only promises" issue can be solved like this, between lines 16 & 17 of lib/Mojo/Promise.pm: ($results->[$i] = $promises[$i]), next unless $promises[$i] && blessed $promises[$i] && $promises[$i]->can('then');
07:56 mohawk you'd need to --$remaining, obvs
08:17 mohawk (in fact, sorry - re-read the first line and ->all is not just an instance method! but the first promise given needs a ->_clone, while all the others only need a ->then)
08:20 marty joined #mojo
08:29 mohawk and this beautiful monstrosity ensure the "all" promise will be a Mojo one: perl -MData::Dumper -MMojo::Promise -e 'sub all_wrap { Mojo::Promise->new->resolve->all(@_)->then(sub { shift; @_ }) } all_wrap(Mojo::Promise->new->resolve("hi"))->then(sub { print Dumper \@_ })->wait'
08:44 dod joined #mojo
08:50 dod joined #mojo
08:59 bianca joined #mojo
09:06 anon joined #mojo
10:26 Leffe joined #mojo
10:28 augensalat joined #mojo
10:30 Leffe joined #mojo
10:41 geospeck joined #mojo
10:42 geospeck joined #mojo
10:43 geospeck joined #mojo
10:53 mohawk i have another question! i'm getting an "Inactivity timeout" which is probably my fault. however, there's a promise running there and it doesn't get rejected, whereas it seems like it should?
11:19 wk mohawk: made PR into your MojoExample, hope it helps a bit
11:43 geospeck joined #mojo
11:58 sri mohawk: i don't care about $promise->all/race, feel free to send a patch deprecating it
11:58 sri it's legacy, from when the module had the name Mojo::IOLoop::Delay and typing Mojo::IOLoop::Delay->all(...) would have sucked
11:59 mohawk sri, great! i will do so
11:59 sri and actually, i don't really care about the renderer accepting promises either, my vote would depend on if the patch is good and gets the votes
12:00 mohawk noted, thanks
12:00 sri (gets the other votes)
12:00 sri as in i'd stay neutral
12:00 mohawk sure
12:01 sri something i forgot to mention in your last pull request, please try to emulate the style of the surrounding code
12:01 mohawk ok
12:01 sri like the test comment didn't fit in at all
12:01 mohawk for the future, if there are style nits, please mention them
12:01 mohawk ok
12:01 geospeck joined #mojo
12:02 mohawk do you have a perlcritic settings there? i've never used it but am willing to try new things ;-)
12:02 sri no
12:02 mohawk i'll use my judgement, then
12:02 mohawk any thoughts on the inactivity timeout?
12:03 mohawk i've set all the DEBUG env vars i can find, and the failing chain goes like this:
12:03 sri please refresh my memory
12:03 mohawk Test::Mojo POST -> /graphql, which returns a promise that will GET /api, and then post-process result
12:04 mohawk sorry, specifically GET /api/echo?arg=Yo
12:04 sri you lost me
12:05 mohawk the concept is that /graphql's resolver for that field (think controller and action) will call an OpenAPI service, process results, and return them
12:05 mohawk this all works splendidly when the OAPI service is remote
12:06 mohawk (and now the graphql works with promises, that bit's ok too)
12:07 mohawk the test i have has routes for the OpenAPI server, under /api, and a GraphQL server, on /graphql
12:07 mohawk make sense so far?
12:11 mohawk what i know is that when Test::Mojo calls into the internal route, it works fine and i assume it's not going over IP at all, just internal
12:12 mohawk i also know that that UA isn't getting used by OpenAPI::Client to make its second call, and i suspect it's trying to go over IP, and deadlocking
12:14 sri Test:Mojo always uses sockets
12:14 sri for /foo requests it spins up its own server
12:14 mohawk as i suspected
12:14 mohawk that's a M::UA::Server?
12:14 mohawk (just reading the code)
12:14 sri yes
12:15 sri so all your tests are as realistic as possible
12:15 sri and since mojo servers are extremely efficient, it doesn't harm test performance
12:16 mohawk is the ua different in T::M from in normal use?
12:16 sri no
12:17 mohawk in the successful case, the server looks like it's emitting an accept, and going on from there
12:17 mohawk that doesn't happen in the failing case
12:17 mohawk the UA emits the same things up to that point in both cases
12:20 mohawk wk, i'll check in a bit - thanks!
12:21 mohawk sri, any thoughts on the promises getting rejected on connection error?
12:21 mohawk seems to me they should be, and currently it looks like no
12:24 mohawk good news, everyone!
12:24 mohawk i'm an idiot
12:25 mohawk so OpenAPI::Client has a facility to use the local app, if you give the app as an argument
12:25 mohawk GQL::P::Convert::OpenAPI faithfully has that facility too
12:25 mohawk and my test wasn't supplying that, so it was going over the wire
12:25 mohawk soon as i add that arg, boom! it works
12:26 mohawk so that's a good thing
12:26 mohawk batman++ # for good design
12:26 mohawk i still think the promise not getting rejected on connection error is bad and i will have a look at that
12:32 mohawk sri, thanks for your assistance!
12:36 mohawk this will mean being able to run a graphql service alongside another mojolicious app
12:37 mohawk (ie one that provides a REST api)
12:46 mohawk wk, merged - you're a star!
12:57 mohawk sri, to detect whether something is a promise, do you think it's overly clever to have Mojo::Promise->is($might_be_promise)?
12:59 AndrewIsh joined #mojo
13:22 sri mohawk: i think there would have to be a very good reason for api extensions
13:22 sri from which promise implementation are you copying that?
13:34 wk mohawk: glad it helped!
13:49 zivester joined #mojo
14:40 marcus Purl, his point 1?
14:40 purl marcus: bugger all, i dunno
14:49 purplecoffee joined #mojo
16:25 trone joined #mojo
16:29 FROGGS joined #mojo
16:38 geospeck joined #mojo
16:44 ghenry joined #mojo
16:44 ghenry left #mojo
16:56 dod1 joined #mojo
17:13 karjala_ joined #mojo
18:19 ChmEarl joined #mojo
19:01 a6502 joined #mojo
19:02 bianca joined #mojo
20:05 mohawk sri, it's intended as an inverted "isa" that's always safe to run. it's not a specific promises thing
20:17 Grinnz mohawk: more useful would just be doing blessed $foo and $foo->can('then')
20:18 Grinnz if you want to do it more concisely you can use Safe::Isa and do $foo->$_can('then')
20:38 mohawk Grinnz, agreed. i saw that a couple of times in the source code (which i c+p-ed above, as you'll have seen), and had the urge to avoid repetition
20:39 mohawk (the blessed && ->can)
20:39 * mohawk checks to see if Safe::Isa is in core
20:39 Grinnz no
20:40 mohawk tragically i fear sri will not be receptive to adding that to Mojolicious
20:40 Grinnz i wasn't talking about for Mojolicious
20:40 mohawk well, i was
20:41 mohawk i use GraphQL::Error->is, it's safe without an extra dep and it's nicely concise :-)
20:51 karjala_ joined #mojo
21:22 geospeck joined #mojo
21:23 geospeck joined #mojo
21:31 bianca joined #mojo
22:15 zivester joined #mojo
22:33 marty joined #mojo
22:52 zivester joined #mojo
23:04 bianca joined #mojo
23:05 bianca joined #mojo

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