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

IRC log for #mojo, 2016-09-30

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

All times shown according to UTC.

Time Nick Message
00:25 asarch joined #mojo
01:41 kaare joined #mojo
02:05 noganex joined #mojo
02:16 ccakes joined #mojo
04:11 polettix joined #mojo
04:12 inokenty-w joined #mojo
04:54 ccakes joined #mojo
05:04 Phil21 re: time series, from the stuff I semi keep up on and friends who use it, seems openttsb and influxdb are the two most sane options now for scaling and ease of use
05:04 Phil21 influxdb I think is more of a paid option though
05:04 Phil21 as that's the direction they are going with all the stuff that matters for scaling
05:05 Phil21 opentsdb I need to catch up more on, the pace of development of this stuff is pretty quick
05:05 Phil21 but my bit dated take on that was it's what you run if you have some OG hackers to run it for you
05:06 Phil21 and really needed scale
05:06 Phil21 but lots of new stuff combined with very mature projects coming around lately (riak, cassandra, mongo, even postgres, etc.)
05:07 Phil21 it's kind of exploded in the last 6-12mo
05:07 Phil21 people realizing how big the market is going to get for such data :)
05:35 cpan_mojo Mojolicious-Plugin-RussianPost-0.01 by KOSTYA https://metacpan.org/release/KOSTYA/Mojolicious-Plugin-RussianPost-0.01
05:43 dod joined #mojo
05:48 dod joined #mojo
05:49 itaipu joined #mojo
06:06 mattp_ joined #mojo
06:35 mbudde joined #mojo
06:59 AndrewIsh joined #mojo
07:14 trone joined #mojo
07:19 mattp_ joined #mojo
07:20 tyldis The Mojo documentation could benefit from some details around memory leaks, but I don't think my skills are at the right level.
07:21 tyldis If you are oblivious to the problem (like me, finding Mojo just magical and don't think about circular references at all...) you can really do some silly stuff ;)
07:26 mpapec tyldis++
07:28 mpapec relevant blog: http://blogs.perl.org/users/joel_berger/2014/07/non-blocking-mojolicious-apps-are-even-easier-now.html
07:34 mpapec joined #mojo
08:27 osfabibisi joined #mojo
08:31 tyldis mpapec: Yep, I did find some scattered blog posts about once I detected the problem
08:32 tyldis And I think I did manage to track it down with Devel::Cycle (a new tool in my kit!)
08:43 nic Phil21++  # alerting us to read about OpenTSDB
08:51 rshadow joined #mojo
09:26 sri tyldis: i wanted to write something a few times, but couldn't find the right way to explain it
09:33 tyldis sri: The main problem stems from people like me, who are just imposters and not really developers, and when we start playing with something beyond the basics.
09:36 tyldis I'm not entirely sure how I could have understood the problem if it was casually mentioned in the docs. And it could also be just confusing to start babbeling about that randomly.
09:36 tyldis So yeah, I see your point.
09:38 pink_mist I'd suggest having an entire section devoted to it in one of the tutorials, and linking to that section from bits that are likely to be affected by leaks (but this still leaves the difficult bit of actually writing it)
09:38 pink_mist s/tutorials/guides/
09:39 tyldis A section on perfomance considerations, perhaps
09:41 tyldis Oh well, right now I'm trying to decipher the Devel::Cycle output and figure whats happening. I think I have another leak, but not sure yet. I could just be measuring it in the wrong place. The first leak was rather obvious, though.
09:44 tyldis Root cause: inspired by some code by batman and not fully understanding it. So I blame him.
09:48 nic tyldis++  # getting the hang of how this works
09:50 caesura joined #mojo
09:51 caesura About fat commas : this does not look right, but is : my @array_strings = ("one" => "two" => "three" => "four");
09:52 pink_mist sure it is
09:52 pink_mist looks perfectly fine, just some unneeded extra quotation marks
09:52 pink_mist but they don't hurt anything
09:53 pink_mist I'd suggest my @array_strings = qw( one two three four ); instead
09:54 caesura Yes, in a chat yesterday, I was bemoaning the syntax of mojo in the first tutorials, using =? and lots of barewords, didn't look right to me, but is
09:54 caesura =>
09:55 caesura So to me, => implies a relationship (key/value sort of thing) where there is none
09:55 pink_mist well, teaching you perl isn't something mojo should need to do :P you should know perl beforehand
09:56 caesura I know it a lot better now!
09:59 Dandre Hello,
09:59 Dandre Is there any way to get all parameters in a template, the same way than $c->req->params ?
10:00 sri $c is available in the template
10:00 Dandre or how can I get the underlying controller object in a template?
10:00 Dandre ay ok
10:02 Dandre Global symbol "$c" requires explicit package name at template
10:02 Dandre My be because my version is quite old
10:15 itaipu joined #mojo
10:24 tyldis What a great Friday feeling. I learned something and I fixed something. Memory usage 100% stable. Didn't look good when I leaked a bit of memory each polling cycle on a device, several times per second...
10:24 csson joined #mojo
10:42 howitdo joined #mojo
10:43 howitdo joined #mojo
10:47 batman tyldis: what have i done?
10:48 tchaves joined #mojo
10:49 tyldis batman: Just kidding. I learend from your Mojo::IRC code, but didn't fully understand everything. TL;DR memory leaks.
10:50 batman ok :)
10:51 batman i don't understand most leaking issues... i always have to test them with https://metacpan.org/pod/Test::Memory::Cycle (i think)
10:51 batman when i say "don't understand" i mean that it's perfectly fine to have cycles sometimes
10:52 batman as long as the code "untangles" itself correctly
10:53 tchaves1 joined #mojo
10:55 tyldis batman: Yup, I went down that path. I had a real one, then I started seeing them everywhere - before realizing I might just be testing befoe it untangled itself. This is probably the hard part with callbacks especially.
10:56 batman yeah. i never test cycles inside a callback. i tend to check the $obj after the async stuff has completed
10:57 tyldis I have a lot of recurring ioloops in this project. And I culdn't quite find the ideal way to handle it.
10:58 batman you could cancel the recurring timer
10:58 tchaves joined #mojo
10:58 tyldis In the end that part I just had to enable loop by loop until I found one that caused memoty to grow. And found my typo.
11:05 mpapec what happens when variable gets weakened but shouldn't be?
11:06 pink_mist things break
11:06 mpapec it gets collected?
11:13 batman yeah... it will act like as if the variable goes out of scope
11:40 blonewolfs joined #mojo
11:59 arpadszasz joined #mojo
12:16 hummeleBop joined #mojo
12:20 hummeleBop joined #mojo
12:31 gizmomathboy joined #mojo
12:37 dod joined #mojo
12:37 rchen joined #mojo
12:37 rchen left #mojo
12:37 rchen joined #mojo
12:38 rchen left #mojo
12:38 rchen joined #mojo
12:40 ptolemarch joined #mojo
13:13 ramortegui joined #mojo
13:54 zivester joined #mojo
13:57 dod joined #mojo
14:29 CHYC joined #mojo
14:56 oalders joined #mojo
15:04 disputin joined #mojo
15:14 itaipu joined #mojo
15:37 asarch joined #mojo
15:44 tohil joined #mojo
15:45 caesura joined #mojo
15:46 lluad joined #mojo
15:56 mcsnolte joined #mojo
16:30 dod joined #mojo
17:08 disputin joined #mojo
17:16 blonewolfs i'm getting an error: Use of inherited AUTOLOAD for non-method Katello_Data::Controller::DataExport::uri_call() is deprecated
17:17 blonewolfs what is the correct way to load a plugin?
17:17 stefan If I have a string that is a URL, can I do something to compare that against the route table and extract a parameter from it?  e.g.  $url = 'http://127.0.0.1:44499/admin/users/2/edit';  How could I do a query for 'id' and extract the 2?
17:18 blonewolfs stefan: /^.*?\/\(d+)\/edit$
17:19 blonewolfs $1 = 2
17:19 stefan blonewolfs Thanks!  But that's not taking advantage of the framework!  :D
17:20 blonewolfs sorry, i don't know how to do it in a mojo style.
17:22 jberger stefan: are you already in the route?
17:22 stefan jberger No, writing tests
17:22 jberger or you want to do like a fake route
17:22 jberger ewwww, no, tests should be dumb
17:23 jberger once a test gets too clever then how do you know what you are testing?
17:23 stefan Oh...  I wanted to extract the ID that was created so that I could then edit it.  How else could I?
17:23 jberger the response is only a url?
17:23 stefan Test #1: POST /admin/users
17:24 stefan Test #2: PUT /admin/users/XXXX  ???
17:24 jberger sure, it makes a new user and returns what?
17:24 jberger rest would tell you that is should return a user object
17:24 jberger or at least an id
17:24 jberger returning a url is strange
17:24 stefan It then redirects to /admin/users/2/edit
17:25 itaipu joined #mojo
17:25 jberger then, I almost agree with blonewolfs, but I'd do it as
17:25 jberger Mojo::URL->new($url)->path->parts->[2]
17:26 jberger (depending on how you get the url it might already be a Mojo::URL)
17:26 stefan What about the # Match of the Synposis here?  http://mojolicious.org/perldoc/Mojolicious/Routes/Match
17:27 jberger stefan: there is almost definitely a way to do it like you are saying
17:27 jberger but, do you want your tests to be that clever
17:27 jberger ?
17:28 stefan Idk!  I'm writing my tests to walk thru the usage of the app...
17:28 stefan Or how else can I test my Controllers?
17:29 jberger if you wanted to "cheat" just a little bit, but be a bit more helpful too
17:29 jberger before you redirect you could add a header with the created object id
17:29 jberger X-CREATED-USER-ID or some such
17:29 stefan Ah, I've been doing that!  :D  Thought that since the ID is already in the 302 Location header that I wouldn't need to add another header.
17:30 stefan $match->stack->[-1]->{user_id}
17:30 jberger right it is CONTAINED, but it isn't easily accessible
17:30 jberger headers are good for adding relevant information more accessible even if it doesn't fit the overall model
17:31 stefan Good!  Glad to know that my "cheating" is an "approved" method!  :D  I did kind of worry about what I was doing...
17:31 jberger stefan: here's the thing about reruning a match on it, I myself would have to really read to be comfortable doing that, and even then I'd think that the test was being too clever
17:33 jberger looks like redirects can have bodies too, though I'm guessing that your users might not want to see a quick flash of a json object or something :-P
17:35 stefan What's the uncomfort?  What's wrong with being too clever?  If I need to follow up on a new URL that was generated by the app, how else to do so but to grab that URL and extract the unique bit?  And then what if the route pattern changes?  That breaks all the tests...  Mojo::URL->new($url)->path->parts->[2] doesn't get to a named parameter, but, AFAICT, $match->stack->[-1]->{user_id} does.
17:35 stefan I'd definitely like to learn the best practices and avoid the worst offenders!  :D
17:36 jberger so yes, named routes do help avoid having to go through and change lots of code when you change the route structure
17:36 jberger and there could be a case for trying to make your tests do that too
17:36 jberger personally I don't
17:36 stefan Yeah!  :D  But what leads to your discomfort?
17:36 jberger because I don't want my routes to accidentally/unexpectedly change
17:37 jberger like if someone adds an under with a path that effects the wrong route
17:37 stefan And how would you test for PUTing to a new URL that was just created after POSTing?
17:37 jberger my tests would happily pass
17:37 jberger but my users might be unhappy
17:38 jberger honestly I usually hard-code most urls in my tests because I want them to be exactly what I expect
17:38 stefan Perfect!  That's a great answer!  :D
17:38 jberger every now and again it can be difficult so I extract an id or something from a returned result
17:39 jberger but usually, if I can hard-code the expected value I do
17:39 stefan That will change how I approach tests now.  That was a fundamental misunderstanding of the usage of tests.
17:39 jberger so yes, in that case say I do intend to change the route path, the actual code remains mostly unchanged because of using named routes
17:39 jberger but the tests have lots of changes
17:40 jberger this means the noise in the commit diff is limited to the change in my expectations and that one change in the router
17:40 jberger cool
17:40 stefan My tests start with a clean database.  When I add the first user I know it should be 1, so I can easily hard code 1.  And I see now that I should.
17:40 jberger probably, though generated ids are more tricky than routes
17:41 jberger you don't necessarily need to expect what an id is
17:41 jberger so this is where sticking it in a header might actually be the best
17:41 jberger "this is what I DID" then later check that what it did was correct
17:41 jberger but that's up to you
17:41 jberger I think you get the idea now
17:42 jberger you could also look up the created user in the database from the tests to get the actual id out
17:42 jberger but that level of detail is up to you again
17:42 stefan That makes a tremendous amount of sense!  Thank you!!  (Document that in Mojo::Test  :D ... that tests shouldn't be so clever and should specify exactly what you expect)
17:43 stefan Ah, another good solution!!  I like that!
17:45 stefan Oh, man!  That was the best, easiest, and most obvious solution!!  my $doe = $t->app->admin->users->find_by_email('john@doe.com')->{user_id};
17:46 jberger now you can check that the url is what you expect, rather than assume the url is correct and use it to get the id :D
17:46 stefan Yep!  Thank you!
17:47 jberger np
17:47 stefan That *also* makes a lot of sense!  Such good stuff!  Where's the best place for advice like this?  A Mojo::Guide?  Or just in a wiki...?
17:47 jberger wiki or blog post
17:47 stefan k!
17:47 stryx` joined #mojo
17:47 jberger the documentation isn't really the place to teach best programming practices
17:48 jberger the *mojo* documentation
17:48 jberger these principals hold true for basically all testing
17:49 jberger lets see, my test philosophy as bullet points (and I'm not a TDD person so they would certainly disagree):
17:49 jberger 1) test at least the happy path (when everything works right)
17:50 jberger 2) test more rigorously in places that matter most
17:50 jberger 3) never be too clever in a test
17:50 jberger 4) always add regression tests
17:50 jberger if you aren't going to do TDD that's fine, but you should NEVER be bitten by the same bug twice
17:51 PryMar56 joined #mojo
17:54 stefan What is meant by "regression" tests?
17:56 stryx` joined #mojo
17:57 stefan Sorry, I should probably Google that.  I'm sure that's not Mojo or even Perl specific!!
17:58 jberger one you have a bug and you fix it, be sure you add the test that would have caught it
17:58 jberger you don't want to regress
18:01 stefan Simple!  Thank you for the explanation!
18:07 stryx` joined #mojo
18:27 zivester joined #mojo
18:53 dod joined #mojo
19:02 jberger https://twitter.com/vuejs/status/781931137937571840?lang=en
19:02 jberger Vue 2.0 released
19:20 vicash jberger++ on the regression test oneliner definition
19:30 blonewolfs i'm trying to create a mojo plugin package and i successfully registered the first function.  how do i add a second function that is globally accessible?
19:32 tyldis blonewolfs: Are you talking about a plugin that registers multiple helpers?
19:33 blonewolfs yes
19:37 tyldis blonewolfs: Did you call app->helper( helper_name => sub { ... } ); somewhere? You can do multiple of those
19:37 tyldis Otherwise I think we need to see some code
19:38 blonewolfs i did that in the register sub inside my package.  when i had just one, it worked fine.  when i added the 2nd everything blew up.
19:39 blonewolfs if having multiple helper calls in the routine is the correct way to do it then i probably just typo'd something adding the 2nd one and it just isn't obvious to me yet.
19:42 jberger blonewolfs: yes you can call helper multiple times in a single register method, so yes, almost certainly problem in your code
19:43 mgrimes_ is it possible to catch exceptions thrown in controllers?
19:46 blonewolfs tyldis, jberger: thanks.
19:49 vicash mgrimes_: use Try::Tiny to catch code exceptions... if you're talking about $c->reply->exception then I don't know
19:50 Grinnz https://metacpan.org/pod/Mojolicious::Guides::Rendering#Rendering-exception-and-not_found-pages
19:51 Grinnz if you need to catch it and continue processing a page, then you should be using Try::Tiny around whatever threw the exception
19:52 Grinnz but if you want to change what gets shown when an exception gets to the renderer, see that guide section
20:06 mgrimes_ Grinnz: vicash: thanks, but I'm trying to simplify my controllers by moving the try{} blocks up a level.
20:07 mgrimes_ I'm writing an API where my models can throw HTTP::Throwable exceptions. I'd like to let them bubble all the way out of the controller, and be turned into json responses.
20:09 jberger that might be possible with a before_render hoo
20:09 jberger hoo
20:09 jberger ummm, helllo "k" key ...
20:09 jberger works now
20:10 Grinnz mgrimes_: then see the third example in the linked documentation
20:10 Grinnz that's exactly what it's for
20:11 Grinnz jberger: looks like sri isn't the only one who needs a new keyboard
20:11 jberger heh, I think I just need to type slower
20:12 jberger bt blmin it o te ey iseaser
20:13 Grinnz with a proper mech keyboard you could type as fast as you want :P
20:13 jberger not pressing the keys doesn't work no matter which keyboard you have
20:14 Grinnz yeah, but it's easier to press those keys quickly
20:14 Grinnz (depending which style)
20:14 Grinnz certainly on reds and browns :P
20:17 * sri still wants the corsair k65 rgb
20:18 mgrimes_ jberger: thanks that perfect
20:57 zivester joined #mojo
21:15 stryx` joined #mojo
21:22 disputin joined #mojo
21:35 disputin joined #mojo
21:35 CW joined #mojo
21:53 sri heh, actually i might just get a razer keyboard after all ;p
22:36 bit_shifter What would be the least expensive way to just return an HTTP 200 to a POST?  render(text => '') works, but I'm not sure if that's more expensive to do than is necessary.
22:37 pink_mist perhaps using data => '' might be slightly less expensive?
22:37 pink_mist maybe
22:39 bit_shifter So, render has to be called either way?
22:52 sri https://github.com/kraih/mojo/blob/master/examples/fast.pl#L5-L6
22:53 sri slightly faster
22:53 sri difference should be pretty meh though
22:59 marty joined #mojo
23:00 bit_shifter sri: Nice, thanks.
23:17 mad_hatter joined #mojo

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