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

IRC log for #mojo, 2014-12-11

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

All times shown according to UTC.

Time Nick Message
00:11 Averna joined #mojo
00:56 mattastrophe joined #mojo
00:59 sri famous last words
00:59 purl Join the army, it'll be fun!
01:05 franzkafka Simple question (I believe): What method do I use to grab the headers from a Mojo::Transaction object?
01:06 franzkafka Say eTag, or something like that
01:06 Grinnz $tx->req->headers
01:06 Grinnz huh?
01:06 franzkafka I am looking at the documentation here: http://mojolicio.us/perldoc/Mojo/Message/Request
01:06 franzkafka And I do not see headers method
01:06 Grinnz it is in Mojo::Message
01:07 franzkafka God dammit, I always forget to check the methods it inherits
01:07 sri http://mojolicio.us/perldoc#REFERENCE
01:07 Grinnz that damn inheritence gets me every time :P
01:07 franzkafka well I will be damned, there's a ton of stuff I was looking for! Thanks Grinnz :D
01:07 franzkafka sri, I want to hug you right now
01:08 * franzkafka hugs sri
01:08 sri we don't even use multiple inheritance or roles
01:08 sri \o/
01:08 Grinnz heh yeah
01:08 franzkafka sri, that is going to save me so much time from now on. Thank you! I always come in asking about this or that, and then I realize it's inherited.
01:08 Grinnz its just, i am always looking at a Mojo::Message::Request or a Mojo::Transaction::HTTP or whatever for something :P
01:08 franzkafka Grinnz, me too :D
01:09 Grinnz well, because that's what you get linked to
01:09 sri and there is always multiple links to the superclass
01:09 sri http://mojolicio.us/perldoc/Mojo/Message/Request#METHODS
01:10 Grinnz yeah but that doesn't help the table of contents :P (and I know, you can't put everything there)
01:10 Grinnz i just tend to look there for "what methods does this object have"
01:25 chansen Reading the code tend to be more rewarding than reading the docs, nothing unique for the majority project
01:27 Grinnz not if you want forwards-compatible code :P
01:29 chansen Fuck the ios spelling of mojo!
01:29 Grinnz lol
01:30 Grinnz thats it, better rename the project to Majority
01:30 chansen Lol
01:32 firnsy MAJORITY RULEZ!
01:32 chansen Renaming Mojo to King would probably have higher impact :)
01:33 chansen Anyway I need some sleep, but later
01:33 woz joined #mojo
01:42 jberger Grinnz: I hadn't really thought about merging the parent error event and the child $err callback slot
01:43 Grinnz jberger, i was giving it some more thought, i don't know if thats the best approach either, because someone might want an error in the child to be handled differently
01:43 Grinnz in my case, i want it to be handled the same, because i want to keep die as a "blow up the page" exception
01:44 jberger Grinnz: yeah, but the error event doesn't indicate which job failed (if you reuse the ForkCall object)
01:44 Grinnz right, that is one issue, i just create a new object lol
01:44 Grinnz (i'm not sure the $tx handling would work properly if i didn't, anyway)
01:45 jberger Grinnz: that is probably the recommended approach, which is why I never implemented the fork-queue functionality of AE::U::fork_call
01:46 jberger I kinda like the idea of merging them, but I might want to indicate that the error is in the parent or in the child
01:47 Grinnz well the bigger issue i ran into is that i don't even want it to run the callback if the child blows up
01:48 Grinnz so what i'm doing now is sticking the callback that's passed to my helper into a closure that checks that lol
01:48 jberger Grinnz: what's wrong with sub ($self, $err, @result) { return if $err; ... }
01:49 Grinnz but again... that may not be the behavior someone else wants
01:49 Grinnz jberger, extra boilerplate that i can handle in my helper instead
01:49 Grinnz minor i know...
01:49 jberger Grinnz: not everything needs a fancy helper, that delay helper came as a result of a lot of discussion
01:49 jberger for a specific use-case
01:50 Grinnz well this helper is for a specific thing we do in a lot of places already... run a SSH command and return the output
01:50 jberger I like to think that my mojoconf talk kicked it off, but it was marcus that spearheaded a solution, then at the last minute sri and I both wrote essentially the same helper at the same time
01:51 jberger Grinnz: I guess that makes sense
01:51 jberger Grinnz: just make it do what you need, don't worry about being too general at this point
01:52 Grinnz really the only other "slow" thing that we do during requests are database calls, and... i don't want to think about making those async yet XD
01:52 Grinnz given it's mysql...
01:53 human39 joined #mojo
01:53 Grinnz but i could probably do a similar thing for that, just getting a new handle inside the child sub
01:54 jberger Grinnz: found it: http://irclog.perlgeek.de/mojo/2014-07-01#i_8952840
01:54 Grinnz hahah
01:54 Grinnz yeah that helper is awesome. it inspired the one i wrote heavily
02:06 jberger hmmmm, I'm kinda liking the idea of merging the two error mechanisms, I'm thinking it might really simplify the code
02:06 Grinnz so... why did cpantesters only give me results on perls < 5.10.1 after i added the prereq for perl 5.10.1
02:06 jberger and it would mean that the fork_call compatibility function could get the errors
02:06 Grinnz http://www.cpantesters.org/distro/M/Mojo-JSON-MaybeXS.html?oncpan=1&amp;distmat=1&amp;version=0.005
02:06 jberger Grinnz: it does that :/
02:06 jberger checkout the Mojolicious results for example
02:07 Grinnz jberger, so, errors in the child would emit an error event too?
02:07 jberger no, it would all come through the $err slot
02:08 Grinnz how could parent errors come there, that's the sub where the errors would happen :P
02:08 jberger but I would have a blessed error which would have a parent/child indicator
02:08 jberger oh, that's the rub
02:08 Grinnz haha
02:08 jberger Grinnz++ # pulling my head out of my ass
02:08 klapperl joined #mojo
02:09 jberger I knew there was a reason I had done that
02:09 jberger still, I could send things like deserialization error there
02:10 * jberger thinks about it
02:10 Grinnz hmm
02:10 Grinnz i dunno, i kinda prefer it as an exclusive "these are errors from your forked sub"
02:10 Grinnz but i guess in a grey-area way that would be
02:10 Grinnz lol
02:11 s1037989_ joined #mojo
02:13 jberger again, I'm only thinking about it
02:13 jberger hey when did we change sides on this argument :-P
02:14 Grinnz XD
02:15 klapperl_ joined #mojo
02:18 Grinnz the only thing that would really make my code cleaner would be something like a flag that causes it to skip the callback, or i dunno
02:19 Grinnz i guess in delay's case this is handled by that whole event counter thing? i couldn't really make heads or tails of that from the docs
02:19 jberger wrap your callback in another one that returns early (i.e. before calling the passed in callback) if there is an $err present
02:19 jberger but again, that's not usually what you want
02:20 tbushell joined #mojo
02:20 Grinnz yeah thats what i did :P
02:20 Grinnz it either calls reply->exception, or the callback
02:21 jberger ah i see
02:21 jberger makes sense
02:22 Grinnz so yeah i guess a flag like that wouldnt actually help matters, i was thinking about just the error event
02:23 Grinnz i dont have the code in front of me anymore heh
02:26 Grinnz anyway thanks for the module, very helpful :D as i mentioned for this project, SSHing around is a common necessity
02:27 jberger Grinnz: glad you like it
02:27 zivester joined #mojo
02:46 sri what the hell? http://www.cpantesters.org/cpan/report/209dfd02-8068-11e4-bdf9-8eb141983e00
02:57 jberger yeah
02:57 jberger ergh
03:04 good_news_everyon joined #mojo
03:04 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/-gRsfA
03:04 good_news_everyon mojo/master 4f9aaa3 Sebastian Riedel: a few less string evals
03:04 good_news_everyon left #mojo
03:04 sri what the heck... lets try it
03:04 jberger actually I think it should be my $NAME = eval { require Sub::Util; Sub::Util->can('set_subname') } || sub { $_[1] };
03:05 jberger I've just been trying all kinds of permutations
03:05 sri why?
03:06 jberger perl -MSub::Util -E 'say \&Sub::Util::sohgpihdgihdgouhfgoudhgfg'
03:06 sri argh!
03:08 sri indeed https://travis-ci.org/kraih/mojo
03:08 sri wait a minute
03:08 sri looks like i broke something yesterday
03:10 jberger anyway, I do kinda wonder if we should tell LeoNerd that you can require Sub::Util and not have Sub::Util::set_subname
03:11 jberger its not isolated, we've seen it several times
03:11 sri yea
03:11 noganex joined #mojo
03:18 jberger sri: https://github.com/Scalar-List-Utils/Scalar-List-Utils/issues/19
03:18 tbushell joined #mojo
03:18 akhasanov joined #mojo
03:19 franzkafka If I have a path like this: /v0/games?query=Ga&offset=10, how do I add that to a Mojo::URL object?
03:19 franzkafka It's a mix of params and path :/
03:20 jberger franzkafka: to an existing object?
03:20 jberger via accessors
03:20 jberger :-)
03:20 franzkafka jberger, yeah
03:22 woz joined #mojo
03:24 jberger I'm assuming your trouble is that the things you want to add are a combination of paths and parameters and you already have paths and maybe parameters in the base object
03:24 jberger ?
03:26 franzkafka I just did it this way: my $base_url = Mojo::URL->new('https://api.orchestrate.io/v0/'); and then my $url = Mojo::URL->new($next)->to_abs($base_url)->fragment(undef);
03:26 franzkafka where $next = '/v0/games?query=Ga&offset=10'
03:27 sri i guess that fail in master it's a perl bug
03:27 sri good old "Modification of non-creatable array value attempted, subscript -1"
03:27 Grinnz wat
03:27 sri i keep forgetting how to work around that
03:27 sri s/it's/is/
03:28 sri foo()->[0][-1] and foo() returns [[], []]
03:29 * jberger 's mind explodes
03:29 sri you can actually do that just fine in a one-liner
03:29 sri but in some contexts it appears to explode before 5.20
03:30 Grinnz interesting...
03:30 franzkafka jberger, yeah, I have a path in the base object, and I am trying to replace that path with the mix of path and params
03:30 sri https://travis-ci.org/kraih/mojo/jobs/43673892
03:31 jberger franzkafka: admittedly I haven't used to_abs in a while and certainly not for that complex of a thing
03:31 franzkafka the base object is https://api.orchestrate.io/v0/, and I am trying to make the path/params /v0/games?query=Ga&offset=10
03:31 jberger it looks like it has some ability to handle some complex merging, but I would probably to it by hand
03:31 Grinnz franzkafka, usually when constructing URLs it makes things easier to have your query params in a hash..
03:32 Grinnz or array
03:32 Grinnz in the case of multiple values...
03:32 franzkafka Grinnz, the path is returned by the API as a value in a JSON object, as you see it.
03:32 Grinnz ahh
03:32 franzkafka Like so: 'next' => '/v0/games?query=Ga&offset=20',
03:32 jberger $base->path($new->path)->query($new->query) or something like that
03:32 Grinnz my next step would be to parse the URL then, but maybe Mojo::URL can use that somehow
03:32 jberger $base->clone-> ... obviously
03:33 Grinnz Mojo::URL does have a parse method
03:34 franzkafka Grinnz, thank you! I think I may be able to do it that way.
03:40 franzkafka hahaha
03:40 franzkafka Seg fault :D
03:40 Grinnz what is this, C?
03:41 jberger quoi?
03:41 Grinnz if you're happy and you know it segfault
03:42 franzkafka it's happy then
03:44 nicomen franzkafka: did you solve it?
03:45 franzkafka not yet, just tinkering now
03:45 franzkafka I did cause some deep recursion errors and a segfault though :D
03:48 Eke- joined #mojo
03:48 jberger franzkafka: did you try it my way?
03:50 franzkafka ok, so this is what I did: has secret_url => undef;, $self->secret_url(Mojo::URL->new($self->base_url)->userinfo($self->secret)); my $url = Mojo::URL->new($data)->to_abs($orchestrate->secret_url)->fragment(undef);
03:50 franzkafka that works
03:50 franzkafka in my base class secret_url and $self->secret_url is set... then I just use that with to_abs and the path/params to construct a new URL
03:51 franzkafka jberger, I did not try your way... I don't know what $new is in $new->path... my assumption was that it was a Mojo::URL object
03:52 jberger yeah, it was your relative path
03:52 franzkafka jberger, I do think though that parse or your way would both have worked.
03:52 franzkafka jberger, want me to try and see?
03:52 jberger up to you
03:53 franzkafka jberger, I will, just for giggles :)
03:53 jberger do what works
03:53 good_news_everyon joined #mojo
03:53 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/pVj8DQ
03:53 good_news_everyon mojo/master 724969c Sebastian Riedel: fixed compatibility with older versions of Perl
03:53 good_news_everyon left #mojo
04:04 powerman joined #mojo
04:06 powerman is there exists any mojo idiom for using Mojo::IOLoop->delay() to download sequence of web pages one-by-one without knowing how many of them should be downloaded (i.e. when you follow navigation on website using "Next >>" links)?
04:08 powerman maybe play with $delay->remaining to inject current step back into beginning of remaining steps (using __SUB__)?
04:08 jberger powerman: I was just going to suggest something similar using __SUB__
04:09 jberger you don't even really need delay in that case then
04:10 Snelius_ recursive sub ? with Mojo::UserAgent cb ?
04:18 irq joined #mojo
04:33 KCL_ joined #mojo
04:35 good_news_everyon joined #mojo
04:35 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/pqLenw
04:35 good_news_everyon mojo/master 9a5c2ce Sebastian Riedel: no need for nodes on the other side of the element
04:35 good_news_everyon left #mojo
04:38 sri mongodb is not exactly known for their good decisions, i wonder what's wrong with the new storage engine they've chosen http://www.wiredtiger.com/
04:40 s1037989_ joined #mojo
05:04 KCL joined #mojo
05:11 woz joined #mojo
05:19 lb joined #mojo
05:41 davido_lt joined #mojo
05:50 rem_lex|pivo joined #mojo
05:54 franzkafka With Mojo::Base can I have an attribute (e.g., has blah => ();) that is an array such that I can do my @arr = $obj->blah; ?
05:55 sri that would be a list, not an array, and no
05:56 franzkafka ok, then I have a method that returns an array
05:56 franzkafka :/
05:56 franzkafka thanks sri!
05:57 sri you can't actually return an array, just an arrayref or a list
06:04 powerman left #mojo
06:07 franzkafka sri, this is what I am doing, which works: http://paste.scsys.co.uk/451822
06:15 Snelius_ array it's same list
06:35 nicomen this is weird, parsing a 800k json with Mojo::JSON::decode_json takes < 1s, but when it's fetched via Mojo::UserAgent, and using ->json it takes like 15s
06:41 meredith franzkafka: if you're curious what Mojo::Base's has() actually does: MOJO_BASE_DEBUG=1 perl -e 'package Foo; use Mojo::Base -base; has bar => q[quux];'
06:43 franzkafka oh wow, so it sets $self->{'key'} to the value provided?
06:43 meredith it doesn't really do any magic, just stuffs that in your class
06:43 franzkafka nice, thanks meredith
06:44 franzkafka that's enlightening actually
06:44 meredith yeah, it's pretty much a standard hash-object accessor, but do note that it returns the object at the end when used as a setter. if you do roll your own accessors it's probably Nice(tm) to stick to that style
06:45 franzkafka ok, a design question now. just looking for any feedback on this.
06:46 franzkafka i'm writing a module for the orchestrate api. the api has a search functionality that returns JSON with up to 10 results, and if there's more it also has a key called next with the url.
06:47 franzkafka Here's what I am doing now: http://paste.scsys.co.uk/451829
06:47 franzkafka basically, for each 10 I am returning the JSON data structure. So, each iteration using next returns an array of hashrefs.
06:47 franzkafka What do you guys think on that?
06:48 franzkafka each iteration through, $data is an array of hashrefs containing the 10 search results.
06:48 s1037989 joined #mojo
06:48 franzkafka btw, meredith, I will stick with Nice(tm) :D
06:49 franzkafka Here's the documentation from the API: https://orchestrate.io/docs/apiref#search
06:50 meredith i definitely like hiding that "next" cursor from your user, but wonder if you might just let $res->next return single entries and hide the user from always having to make an inner loop
06:53 franzkafka meredith, ok, I was thinking the same thing... I think I will do it that way. I was even thinking about having the column names be the accessors, like in dbix class (e.g., $rs->genre), but not sure how to deal with values that are arrayrefs.
06:55 meredith what do you mean by deal with them?  decide whether or not to deref and return lists rather than the ref?
06:57 franzkafka Hm, actually, the more I think of it... yeah, what the heck, I am going to do it that way.
06:57 franzkafka I think I will deref and return the list
07:00 woz joined #mojo
07:01 dod joined #mojo
07:10 ver joined #mojo
07:13 Lee joined #mojo
07:22 denis_boyun joined #mojo
07:35 franzkafka I am using attr method from Mojo::Base to create accessors dynamically. I take it this is not possible? E.g., $self->attr(testing => 'test'); then in the script I am doing say $obj->testing; and I am getting 'Can't call method "testing" on unblessed reference'
07:37 franzkafka Got it, I think. I need to return $self.
07:45 Vandal joined #mojo
08:13 eseyman joined #mojo
08:13 franzkafka damn, looks like column names as accessors is out...
08:14 franzkafka from mojo base attr sub: Carp::croak 'Default has to be a code reference or constant value' if ref $default && ref $default ne 'CODE';
08:14 franzkafka meaning, $self->attr(key => [ @array ]);, etc will not work
08:20 woz joined #mojo
08:22 sugar joined #mojo
08:23 trone joined #mojo
08:24 batman franzkafka: are you trying to modify the instance ($self) or a class?
08:25 batman Modify = add an accessor
08:25 franzkafka I guess I'm trying to modify the class
08:26 franzkafka the $self->attr(key => 'value') does set an accessor on the class if the value is a scalar, but not an array.
08:26 basiliscos joined #mojo
08:30 batman In runtime? I don't think that's a good idea.
08:31 batman And I'm not sure that's what you want... I would urge you to go back to the drawing board.
08:31 batman It is possible though.
08:32 franzkafka Hm, ok. I was trying to do something like DBIx::Class, wherein you do something like while ( my $cd = $rs->next) { say $cd->title; }
08:32 franzkafka The accessors would be dynamic (i.e., I don't know the data set of the person using the module), so I was creating them dynamically based on what columns their data set contains.
08:33 franzkafka If that is a bad idea, I could go with my initial which would be to return a hashref, and they'd do something like say $rs->{column}; or for ( @$rs->{column} ) { }
08:39 batman you could do sub get_column { $_[0]->{data}{$_[1]}; }
08:40 franzkafka yeah, I have a get_column method (I like your code better though :))
08:40 franzkafka ok, so I think I will just return a hashref then
08:45 zz_Foxcool joined #mojo
09:08 batman does anyone know how to check if a number is a valid "float" ?
09:10 absolut_todd joined #mojo
09:16 Snelius_ =~ /\./
09:16 Snelius_ :)
09:17 nicomen $RE{num}{real}
09:17 nicomen from https://metacpan.org/pod/Regexp::Common
09:18 Snelius_ RE_num_real()
09:21 nicomen $ perl -wlE 'use Regexp::Common; print m{$RE{num}{real}} ? "ok: $_" : "nok $_" for (qw(1.23 3e4 1.000002 LOL 0.1.2 -1 -45 a 1_3456_632 ))'
09:21 nicomen ah right ;)
09:21 nicomen 0.1.2 matches though :-(((
09:22 Snelius_ =~ /\./ it's same result )
09:25 irq joined #mojo
09:32 fhelmberger joined #mojo
09:32 fhelmberger joined #mojo
09:40 batman nicomen: i don't want to match a double
09:44 franzkafka what about =~ /\d+\.\d+/ ?
09:45 preaction you mean "can be represented with full precision in a float?"
09:46 franzkafka Here's the regex perldoc is using: /^[+-]?(?=\.?\d)\d*\.?\d*(?:e[+-]?\d+)?\z/i
09:46 franzkafka http://perldoc.perl.org/perlfaq4.html#How-do-I-determine-whether-a-scalar-is-a-number%2fwhole%2finteger%2ffloat%3f
09:48 franzkafka I notice Mojo::Header has an if_none_match method (http://mojolicio.us/perldoc/Mojo/Headers#if_none_match). Any reason there isn't an if_match method?
09:50 preaction my guess is that one doesn't get used much in the wild
09:50 batman franzkafka: i think that regex checks if it is a number. i need to check the precision as well...
09:51 batman for this: https://metacpan.org/pod/Swagger2::SchemaValidator#formats
09:54 batman one idea was to check if length($number) <= 42 or something, but i have no idea what the max length could be...
09:56 franzkafka Have you seen this: http://perldoc.perl.org/Math/BigFloat.html ?
09:56 franzkafka specifically:  ($l,$f) = $x->length(); # number of digits, and length of fraction
09:57 franzkafka and: $x->precision(); # return P of $x (or global, if P of $x undef)
09:58 franzkafka preaction, yeah, good point. I just found it odd that one half of it is there: If-None-Match but not If-Match
10:11 McA joined #mojo
11:03 neyasov___ joined #mojo
11:07 neyasov____ joined #mojo
12:03 asarch joined #mojo
12:06 absolut__ joined #mojo
12:35 amon joined #mojo
12:45 Ralesk argh of course it doesn't quite work on Windows, damn that platform
12:56 neilhwatson joined #mojo
13:07 punter joined #mojo
13:13 tencendur joined #mojo
13:27 ignacio_ joined #mojo
13:36 neilhwatson joined #mojo
13:37 dotan joined #mojo
13:59 akhasanov joined #mojo
14:05 marty joined #mojo
14:12 sugar_ joined #mojo
14:13 tbushell_ joined #mojo
14:13 tbushell_ joined #mojo
14:14 tbushell left #mojo
14:18 Ptolemarch joined #mojo
14:20 tbushell joined #mojo
14:21 tbushell left #mojo
14:21 kua joined #mojo
14:29 neyasov____ joined #mojo
14:30 neyasov_____ joined #mojo
14:42 sri damn
14:43 sri this is really bad https://github.com/kraih/mojo/issues/716
14:43 Grinnz just saw that
14:44 Grinnz can IO::Socket::IP do something to prevent the problem?
14:44 sri jberger, tempire, marcusr, crab, batman: we have to make a decision
14:45 jberger could only load NDN if IO::Socket::IP isn't already loaded
14:45 sri for the record, if no decision can be made i'll default to the removal of Net::DNS::Native support
14:48 sri IO::Socket::IP is core and its use encouraged, it will be already loaded more and more in the future
14:48 jberger hmmmm, good point
14:48 purl nice and sharp
14:48 jberger purl: botsnack
14:48 purl :)
14:51 Grinnz "Btw [Tux] from #p5p promised to add "linking with pthreads by default" feature few months ago."
14:51 Grinnz that's what would need to happen to really fix this right?
14:52 sri that would only help with perl 5.22+
14:52 Grinnz mmm
14:53 Grinnz right, to support older perls jberger's option is probably the only safe way to load it
14:54 akhasanov joined #mojo
14:55 sri jberger: and of course, any other xs module you load before Net::DNS::Native might have the same effect
14:55 sri segfault again
14:56 sri that's the real problem, it fails so badly
14:56 jberger right, if it died we would be ok
14:56 jberger could Oleg have NDN check for the loaded symbol and bail out if its already there (I'm not sure if C allows that)
14:57 Grinnz or even better if he could find a way to detect if the wrong one is loaded
15:02 jberger sri: if NDN cannot detect the problem symbol itself then this is essentially a perl bug
15:02 jberger :/
15:03 jberger I still think we could allow it as opt-in, but I agree now, without a fix in place, this cannot be the default behavior
15:07 batman sri: +1 on removing NDN, unless *someone* is actually working actively on a fix
15:07 sri i'm ok with a pluggable resolver api, but someone has to design it
15:08 jberger sri: the old pluggable resolver api isn't salvagable?
15:12 sri what api?
15:12 purl api is probably not fine
15:12 sri botsnack
15:12 purl :)
15:13 jberger I recall that there was a pluggable resolver ages ago, predating me
15:13 jberger you mentioned it before
15:14 sri i don't think it was actually pluggable
15:18 jberger I would just say the plugin would present a purely non-blocking api, its easy enough to just blocking resolve and then call the callback with the result (for a blocking resolver)
15:19 jberger Mojo::Resolver::NDN->new->resolve($address, sub ($resolver, $err, $result) { ... })
15:28 jberger and I would say that the PeerAddrInfo is the thing you expect
15:32 sh4 joined #mojo
15:42 Ptolemarch joined #mojo
15:43 sri https://github.com/kraih/mojo/issues/716#issuecomment-66637493
16:02 disputin joined #mojo
16:12 jberger sri: something along these lines?
16:12 jberger http://pastie.org/9774402
16:12 jberger would need some way to pick the class
16:14 sri right, the hard part is finding a nice way to select the resolver implementation
16:14 sri can't quite put my finger on it, but something bugs me about the whole thing
16:14 mattastrophe joined #mojo
16:15 jberger well, I've spent as much time on it as I can today
16:15 jberger gotta $work
16:16 jberger I have the branch if someone wants to run with it let me know
16:16 sri next release is tomorrow
16:16 sri if we have no proposal i'll go with removal
16:17 jberger there is no actual user impact to removing/adding a couple times?
16:17 sri not really
16:17 jberger other than resolution becoming blocking again
16:17 jberger then I'm ok with that if you want to get the fixes out
16:21 good_news_everyon joined #mojo
16:21 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/vWSGhw
16:21 good_news_everyon mojo/master 3f7dc3f Sebastian Riedel: removed support for non-blocking name resolution with Net::DNS::Native again, because there have been too many problems with segmentation faults (closes #716)
16:21 good_news_everyon left #mojo
16:27 sri on a more positive note, Cpanel::JSON::XS uses the same number detection heuristics as Mojo::JSON https://github.com/rurban/Cpanel-JSON-XS/commit/fc48ace67d03e1f7e373373ed801f1c1e4065bb8
16:29 sri interesting that it turns inf/nan into null
16:32 sri jberger: btw. i think a pluggable api with an optional dependency that's actually opt-in is a new concept for mojolicious
16:32 sri in fact, so far we only have Mojo::Reactor::EV i believe
16:32 jberger right, MR::Ev is the model
16:33 sri being opt-in makes it totally different though
16:33 Grinnz_ sri: nice
16:35 Oleg joined #mojo
16:37 Oleg That was good try :) BTW I liked idea of the pluggable API from the beginning
16:38 Oleg And now we are at the beginning again
16:38 sri problem with the pluggable api is that we have no ideas for good ones
16:40 Oleg I'll think about it
16:40 sri jberger: that "return $self->emit(error => "Can't resolve: $err") if $err;" was a pretty big wtf? for me
16:41 sri right below you have "$self->$cb(undef, \@res);"
16:41 sri i'm assuming that was just an oversight
16:41 jberger sri: oops, yeah, that's wrong
16:42 jberger oh, and it shouldn't be an EventEmitter either
16:43 jberger hahaha, I got myself confused when I saw the emit and decided I needed to inherit from that, I should have removed the emit call :-P
16:43 jberger I was just trying to demonstrate a possible api
16:46 sri Oleg: not quite at the beginning, at least Net::DNS::Native got some real world testing :)
16:47 sri i think the lessons learned will also help any future libuv bindings
16:48 sri now we know that will be a mess as well
16:49 Oleg I am wondering how much domains it had resolved in the real world :D
16:50 Oleg But yes, many lessons learned, and we lost IO::Scocket::INET support in this war :D
16:51 sri right, actually a very valuable lesson, now we know IO::Socket::IP works very well in the real world
16:51 sri http://www.cpantesters.org/distro/M/Mojolicious.html?oncpan=1&amp;distmat=1&amp;version=5.68
16:51 sri all green aside from that shitty Sub::Util bug
16:53 sri jberger: if you have a branch, you forgot to push it
16:56 Oleg joined #mojo
16:57 skiehn joined #mojo
16:58 disputin joined #mojo
16:59 good_news_everyon joined #mojo
16:59 good_news_everyon [mojo] jberger created resolver (+1 new commit): http://git.io/lQvr1A
16:59 good_news_everyon mojo/resolver 93c380d Joel Berger: Very rough outline of a pluggable resolver api
16:59 good_news_everyon left #mojo
17:02 Grinnz_ you didn't actually use Net::DNS::Native in that module :P
17:02 jberger yeah, see, VERY rough cut :-)
17:02 * jberger is actually at $work atm
17:04 sri hmm, do we have another pluggable api that uses the base class directly?
17:04 sri as in Mojo::IOLoop::Resolver->new?
17:04 sri it's usually an abstract base class with two subclasses
17:07 jberger there could be an abstract base class there
17:08 Ptolemarch joined #mojo
17:09 sri anyway, the hard question is still unanswered... how to decide which resolver to use?
17:10 jberger I think there is an env variable, like Reactor
17:10 sri on the plus side, this kind of api will make testing easy
17:10 jberger the docs for ::NDN can warn about the load order of N::D::N
17:10 sri i don't like the env var idea
17:11 sri not for something so essential
17:11 franzkafka good morning everyone!
17:11 jberger franzkafka: o/
17:11 sri it works for the reactor because EV is the default if available, most people never touch MOJO_REACTOR
17:12 jberger ok, so there is a detect method somewhere
17:12 sri env var as a fundamental api for opting into a whole pluggable api system kinda sucks
17:12 jberger but I don't see how we get around the fact that we cannot (reliably) detect when NDN will have trouble
17:12 sri yea, we can't, and that's what makes it so hard
17:13 sri it's either ugly or unrelaibale
17:13 sri s/ai/ia/
17:13 sri s/a//
17:13 sri argh!
17:13 jberger with an env var (or some other opt-in) you can know how to prevent the load order problems and make sure you conform
17:13 franzkafka It should be interesting to see if this has any impact on my scraper with NDN removed, considering installing NDN was what seemed to fix it. Is it possible to opt-in to use it?
17:13 jberger other than that I don't see a solution
17:14 sri franzkafka: it will be completely removed in the next release i'm afraid
17:14 jberger franzkafka: work with sri on coming up with something useful for opt-in
17:14 * jberger chains franzkafka to the channel
17:14 * jberger continues to $work
17:14 sri actually, i'm not sure i have much time to work on this, aside from pointing out problems i see :/
17:16 sri franzkafka: if you want to learn more https://github.com/kraih/mojo/issues/716
17:17 franzkafka yeah, I was reading the bug report. What a nice, detailed bug report! olegwtf++
17:17 jberger also known as Oleg here
17:18 jberger Oleg++ indeed
17:18 jberger now if only we can figure it out
17:18 franzkafka oh yeah, Oleg++ then.
17:18 sri yea, Oleg has been doing great work, which makes this all the more sad
17:19 sri it's tragic perl is not always linked with pthreads
17:19 sri there's many more modules with similar problems... like IO::AIO
17:20 sri or even UV
17:21 sri i still remember how people were excited about UV in the beginning, and it never got popular because of all the random segfaults
17:21 sri THIS IS WHY!
17:21 Grinnz_ :/
17:22 sri this shit has really harmed perl, and nobody noticed
17:23 Oleg Tux will fix this soonish. That he said two month ago :)
17:25 sri i've seen the word "soonish" in open tickets from 2002 ;p
17:26 Oleg :D
17:26 Grinnz_ heh
17:27 Oleg Oh my http://perl5.git.perl.org/perl.git/commitdiff/23705063
17:29 jberger is there access to libswanted or the actual compiled libs in say $Config?
17:29 jberger if so, that is how to make the detect method work for pluggable resolution
17:31 denny joined #mojo
17:33 Grinnz_ hrm.. i have a before_render hook to turn exception and not_found templates in JSON output for my JSON routes, as described here... https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Rendering.pod#Rendering-exception-and-not_found-pages
17:34 Grinnz_ but the reply->exception helper first tries exception.$mode then exception, and i don't want it to use my exception.production template file.... so i'm matching /^exception\b/
17:34 purl Hmm.  No matches for that, Grinnz_.
17:34 Oleg jberger: yes we can check libswanted via Config.pm
17:34 Grinnz_ but, apparently when it calls exception.development, it isn't passing the exception, and i can't figure out why
17:35 Grinnz_ does the exception handling from an actual "die" differ from the reply->exception helper?
17:36 Grinnz_ actually, i have a better idea... i'll go back to matching 'exception' exactly, and just remove the template from the args
17:37 Grinnz_ not sure what's going on there still... but this works
17:40 franzkafka perl -MConfig=config_vars -e 'config_vars('libswanted');'
17:41 irq joined #mojo
17:43 franzkafka There's also perllibs, which would tell you.
17:44 franzkafka Does libswanted require the lib to build?
17:44 franzkafka I.e., if libpthread.so was missing, would it still build?
17:44 franzkafka I guess a `perlbrew install-stable` does not build Perl with pthreads
17:44 franzkafka my system Perl in debian has it though
17:46 Oleg because pthread added to libswanted just few minutes ago, it is not in stable perl yet
17:47 jberger I WANT IT NOW :-)
17:48 Oleg And libswanted doesn't require lib to build, if it exists it will build with lib, if not it will build without lib
17:49 Oleg git clone http://perl5.git.perl.org/perl.git :)
17:49 franzkafka ah ha, so it does not require it then... so you could check libsfound to see if it was actually there.
17:51 Oleg Oh libsfound, cool variable. Didn't see it before. I checked some others https://metacpan.org/source/OLEG/Net-DNS-Native-0.13/lib/Net/DNS/Native.pm#L20
17:56 s1037989_ joined #mojo
17:57 franzkafka I wonder if usethreads would be defined if ithreads were used?
17:57 Oleg yes should be defined if perl built with ithreads support
18:05 dod joined #mojo
18:07 damaya joined #mojo
18:07 basiliscos joined #mojo
18:28 akhasanov joined #mojo
18:38 sri jberger: just had an idea, use MOJO_RESOLVER, but have "use Mojo::IOLoop::Resolver::NDN;" set MOJO_RESOLVER=Mojo::IOLoop::Resolver::NDN automatically
18:39 sri that way the env var dance is hidden, and you just add "use Mojo::IOLoop::Resolver::NDN;" to your app
18:44 jberger sri: works for me
18:51 sri pretty much none of the code in your branch is actually usable :S
18:53 sri hmm, i guess it's better if i stay away from this, it's a good task for volunteers to get into ioloop internals
18:54 * sri has just confirmed that it works
18:56 sri gonna throw away the prototype though
19:10 jberger sri: that's fine, that's all it was
19:11 jberger obviously I didn't test it or even run it
19:14 zackiv31 joined #mojo
19:19 jonasbn joined #mojo
19:29 zackiv31 joined #mojo
19:45 good_news_everyon joined #mojo
19:45 good_news_everyon [mojo] kraih created pluggable_resolver (+1 new commit): http://git.io/xp8Qvw
19:45 good_news_everyon mojo/pluggable_resolver 49acb93 Sebastian Riedel: added basic support for pluggable resolvers
19:45 good_news_everyon left #mojo
19:45 sri jberger: that one actually works
19:48 sri some of it is rather ugly though
19:49 sri i'm not going to finish it
19:49 sri cleanup, tests and documentation are left for volunteers that want to step up
19:50 sri especially this hack is ugly https://github.com/kraih/mojo/commit/49acb9356cfd#diff-4b4175417080883ed2af6e92086dc8f2R43
19:54 tencendur joined #mojo
19:55 Eke- joined #mojo
20:30 oalders joined #mojo
20:51 sri another option would be not to have Mojo::IOLoop::Resolver::NDN in core
20:52 sri or maybe non-blocking resolver support is not worth the trouble
20:52 sri i guess we will have to reevaluate if a real pull request pops up
21:28 Eke- joined #mojo
21:40 alnewkirk joined #mojo
21:44 akhasanov joined #mojo
21:48 punter joined #mojo
21:51 sugar__ joined #mojo
22:04 Ptolemarch joined #mojo
22:29 sri jberger: actually, my proposal was bullshit :(
22:30 sri pluggable resolvers only make sense if we support more than one, but most are event loop specific
22:30 sri so a global switch does not work
22:31 Grinnz_ wouldn't "Net::DNS::Native" and "no Net::DNS::Native" technically be two options :P
22:39 absolut_todd joined #mojo
22:58 panzana` joined #mojo
23:03 human39_ joined #mojo
23:07 Averna joined #mojo
23:24 mattastrophe joined #mojo
23:30 asarch joined #mojo
23:34 tbushell joined #mojo

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