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

IRC log for #mojo, 2017-08-03

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

All times shown according to UTC.

Time Nick Message
01:03 ribasushi joined #mojo
01:28 stryx` joined #mojo
01:49 kaare_ joined #mojo
02:02 noganex_ joined #mojo
02:33 Ptolemarch joined #mojo
02:59 noganex joined #mojo
03:01 tchaves joined #mojo
03:02 itaipu joined #mojo
04:18 mib_89r8kq joined #mojo
04:45 itaipu joined #mojo
05:01 vicash joined #mojo
05:44 stryx` joined #mojo
06:07 stryx` joined #mojo
06:41 AndrewIsh joined #mojo
06:56 karjala_ joined #mojo
06:59 bianca joined #mojo
07:10 Vandal joined #mojo
07:46 sri holy contribution batman... that is a lot to read https://github.com/kraih/mojo/pull/1118
08:09 foursixnine joined #mojo
08:11 sri now that we have to process one more request before a connection can be closed during shutdown
08:11 sri i wonder if the 60 second graceful_timeout is enough
08:12 sri there can be a delay of up to 15 seconds before the last request starts (inactivity_timeout)
08:20 sri now that we spin up spare workers a longer graceful_timeout shouldn't be too bad
08:21 sri only reason not to make it too large would be that websocket connections can't be closed gracefully, and will most likely use up the whole timeout
08:22 sri so, i was thinking maybe 120 second default
08:28 prg joined #mojo
08:38 jberger hmmm, I should have started a review, I didn't think I was going to do the full thing (I still might not)
08:39 jberger yeah, I'm tired, got up early to hike out to LAVA!!!
08:39 jberger and now its late, and lava is hot
08:41 sri i expect reviewing and revisions to take at least a few days
08:41 sri but i do like how the guide flows
08:41 petru joined #mojo
08:41 sri so i'm quite optimistic
08:42 sri (not that i've really reviewed in details, just skimmed through)
08:44 good_news_everyon joined #mojo
08:44 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/v7gE4
08:44 good_news_everyon mojo/master 5c0dcf1 Sebastian Riedel: now that we have to process one more request before we can close the connection, it makes sense to increase the timeout a little as well
08:44 good_news_everyon left #mojo
08:45 jberger the internet is slow here, so I'm still uploading a lot of stuff
08:45 jberger but here is a gif of lava
08:45 jberger https://cloud.jberger.pl/s/14ln10nSLd1mWpS
08:50 good_news_everyon joined #mojo
08:50 good_news_everyon [mojo] kraih tagged v7.39 at eec40e5: https://git.io/v7gup
08:50 good_news_everyon left #mojo
08:50 good_news_everyon joined #mojo
08:50 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/v7guh
08:50 good_news_everyon mojo/master be50b20 Sebastian Riedel: bump version
08:50 good_news_everyon left #mojo
08:52 mishanti1 Perhaps stupid question, but I'm asking anyway: back in the day when I did php I ran into forms posted with `<input name="foocollection[0][somefield]" value="kapow">` which on the server side got translated into `[ { somefield => 'kapow' } ]` when requesting 'foocollection'. Does mojo support something similar?
08:53 simbabque joined #mojo
08:54 sri there are plugins
08:54 sri we've thought about adding support a few times, but the proposals were not good enough i think
08:56 simbabque joined #mojo
09:01 mishanti1 Ah. I see. I'm doing a conversion of a php-app to perl, and some of the forms are like that. I'll look into the plugins and see if those would help. If not I'll just rewrite the input-fields. No biggie.
09:01 foursixnine joined #mojo
09:24 mishanti1 Mojolicious::Plugin::ParamExpand did exactly what I needed. Time saved. Awesome!
09:32 stryx` joined #mojo
09:42 irqq joined #mojo
10:04 android joined #mojo
10:56 tchaves joined #mojo
11:08 yukikimoto joined #mojo
11:24 yukikimo_ joined #mojo
11:35 bianca joined #mojo
11:42 petru joined #mojo
12:03 karjala__ joined #mojo
12:05 sh14 joined #mojo
12:14 karjala_ joined #mojo
12:34 jabberwok In Minion, if you mistakenly pass a scalar or hashref as the second [@args] argument to enqueue(), that will result in an enqueued job that will cause Minion::Job::start to fail with error. Would it be desirable for enqueue to handle that in some other way?
12:37 jabberwok the docs aren't *wrong* at all, tho it does seem inconsistent that [@args] cannot be omitted before the options hashref.
12:38 yukikimoto joined #mojo
12:40 gizmomathboy joined #mojo
12:56 inokenty joined #mojo
13:05 trone joined #mojo
13:17 ashimema what was the final consensus on periodic jobs in minion?
13:18 ashimema to just use cron instead/in combination with minion?
13:18 ashimema any examples of that hanging around?
13:23 itaipu joined #mojo
13:25 Pyritic joined #mojo
13:42 vicash ashimema: if you're using Minion with Mojolicious, then create a route whose sole purpose is to enqueue jobs. Then call "curl/wget $route" from cron. the mojolicious app will then enqueue the job on the request. easily unit testable too.
13:49 Pyritic joined #mojo
13:49 ashimema sounds sensible
13:50 ashimema or one could use a mojolicious command to similar effect I would think
13:50 ashimema just wondered how others do it..
13:50 ashimema currently I actually have one job that reschedules itself as it's last task.. which has been working remarkably reliably
13:54 sri vicash: disagree on that, i think a command is better for enqueueing the job from cron
13:54 sri in fact, that's what i'm doing right now for a work project
13:55 sri have a command 'script/xcdchk sync' which enqueues a unique job every time it is called
13:56 sri it's why i added locks to minion :)
13:56 sri (and now foreground jobs)
13:57 sri at least for me foreground jobs have been working out pretty nicely
13:58 vicash sri: you mean Mojolicious::Command ? yes that is a good idea.
13:59 sri http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Adding-commands-to-Mojolicious
13:59 sri literally what they are for
14:01 * sri likes having app specific commands for all those little maintenance tasks
14:09 CandyAngel Hear hear
14:10 CandyAngel Though I move all the built-in commands under a mojo subcommand too
14:11 karjala_ joined #mojo
14:38 Pyritic joined #mojo
14:45 bianca joined #mojo
14:48 petru joined #mojo
15:02 jabberwok <3 Mojolicious::Command
15:28 trone joined #mojo
15:31 perlpilot_ joined #mojo
15:43 mcsnolte joined #mojo
16:16 PryMar56 joined #mojo
16:19 AirDisa joined #mojo
16:36 karjala_ joined #mojo
17:04 rick_soc joined #mojo
17:05 rick_soc hello!  your favorite person is here
17:18 PopeF oh boy! My favorite person!
17:19 PopeFelix What's the correct way to render a JSON message after an exception in a controller, given that the controller needs to make non-blocking calls?
17:19 PopeFelix Right now the code is doing $c->render( json => { ... } )
17:22 PopeFelix And while that works for blocking calls, I think that's what's causing the IOLoop to be running before I do Future->get.
17:23 * PopeFelix is already doing 'render_later'
17:24 Grinnz in a running ioloop like a web app, you should only ever be calling ->get on a future after you know it's ready
17:24 Grinnz which is usually unnecessary, as you get the results in the callback
17:24 itaipu joined #mojo
17:31 PopeFelix Grinnz, I see what you're getting at, I think, but I don't know how to make that happen.
17:31 Pyritic joined #mojo
17:32 PopeFelix It's my understanding that to start everything processing from a method returning a Future, I need to do $future->get.
17:33 PopeFelix But I can do regular blocking calls (e.g. database I/O) before that.
17:34 Grinnz you are in a running loop. you don't start anything processing. you set up a future chain and callbacks that occur once the non-blocking operation is done
17:34 Grinnz keep a reference to the future and the running loop will trigger it when it's done
17:35 [vlad] joined #mojo
17:36 PopeFelix OK, so I don't need to call ->get on the Future at all, is that what you're saying?
17:36 Grinnz yes
17:36 PopeFelix OK, I'll try that.
17:40 PopeFelix That gives me an inactivity timeout
17:40 Grinnz does the non-blocking operation take longer than 15 seconds?
17:41 Grinnz https://metacpan.org/pod/Mojolicious::Guides::FAQ#What-does-%22Inactivity-timeout%22-mean?
17:41 PopeFelix it shouldn't; it's writing to a local file.
17:41 PopeFelix but i'll check.
17:42 Grinnz are you actually rendering something in your callback when the future is done?
17:42 itaipu joined #mojo
17:42 sh14 joined #mojo
17:42 PopeFelix yes, i think so
17:46 PopeFelix My Future is never getting marked ready
17:48 PopeFelix hm. But the Future returned by the actual put operation is. Looks like I need to dig into this further on my end. Thanks.
17:49 pink_mist if all async you're doing is writing a file on the filesystem, you're not really doing async at all afaik
17:49 pink_mist if you want that to be done async you might need to use a subprocess
17:50 PopeFelix pink_mist, it's writing to the filesystem for testing purposes. In production it will write to S3.
17:50 pink_mist I don't think that's a good test
17:51 PopeFelix oh?
17:52 pink_mist as I said, it doesn't really async
17:52 * PopeFelix is aware.
17:53 PopeFelix In this case, though, the file operations are queued in the IOLoop via $ioloop->next_tick( sub { do_file_operation() } )
17:54 PopeFelix But maybe I was trying to be too clever for my own good there.
18:03 rick_soc my fun task for the day - I'm looking into how to handle Roles/privs in mojo
18:04 rick_soc What I was originally thinking about doing is loading a hash with all the pages the logged in user should have access to, then using that hash on each request to check authorization
18:04 rick_soc then I looked around at what others have done and found different attempts at plugins
18:05 rick_soc Are there any straightforward recommendations in handling this
18:05 chandwki joined #mojo
18:06 chandwki how does garbage collection work with mojolicious controller classes? I'm having an issue where database connections are getting open but never closed when I use them in controllers.
18:06 chandwki I tried putting a warn in a DESTROY method in my controller class and it looks like it never gets called either
18:07 pink_mist sounds like you have a leak then
18:07 chandwki that's not normal?
18:07 pink_mist no
18:07 chandwki I inherited this code from someone so I guess I gotta figure out wtf he did
18:07 PopeFelix :)
18:07 dod joined #mojo
18:08 PopeFelix you might try weakening the $dbh ref
18:08 * PopeFelix is just guessing
18:08 pink_mist it's impossible to say much from this end really
18:08 pink_mist weakening *something* is likely to help
18:08 pink_mist but if it's the dbh or something else is impossible to say
18:08 PopeFelix on the contrary, we can say a great deal. But it is unlikely to be helpful.
18:09 preaction a great deal
18:09 PopeFelix a great deal
18:09 preaction yeah, i don't think i was helpful
18:09 pink_mist yeah, you're not helpful at all
18:09 PopeFelix nope. ;)
18:10 * PopeFelix did discover that his problem with the Future not being marked ready stemmed from building a list of Futures and doing Future->wait_all on them
18:12 chandwki oh, interesting, destroy does get called.... after a while
18:13 Grinnz are you using a connection pool like Mojo::Pg?
18:14 chandwki no, I'm using DBIx::Class
18:14 Grinnz that functions as a connection pool also
18:14 chandwki unless I'm using it wrong
18:14 Grinnz er... why do you care when the controller gets GCd?
18:14 Grinnz is the controller storing a handle?
18:15 chandwki well if I hit the API too many times I eventually get an error "error] DBIx::Class::Storage::DBI::catch {...} (): DBI Connection failed: DBI connect(#######) failed: Too many connections"
18:15 preaction how many forked children do you have?
18:17 chandwki one i think
18:17 chandwki I'm using morbo for development so that's only one right?
18:18 preaction yes
18:19 chandwki I'm also using the OpenAPI plugin so maybe that's doing something funny
18:20 preaction it isn't
18:21 chandwki I'm setting up my DBIx:Class connection in a builder method for an attribute using Moo, maybe moo is doing something funny?
18:21 chandwki just gonna try things XD
18:22 preaction you could move your connection to a helper on your app
18:22 chandwki that's an idea
18:25 petru joined #mojo
18:27 chandwki oh, so DESTROY gets run when I make a change and morbo reloads
18:28 preaction yes, that's global destruction
18:36 irqq joined #mojo
18:39 bianca joined #mojo
18:41 chandwki but like... an instantiated controller class should get garbage collected after the request is done right?
18:50 chandwki yeah, tested another app I wrote for a personal project, that totally should be happening
18:50 chandwki wtf did this guy do XD
18:51 preaction are you using async callbacks? those are easy to make leak
18:55 chandwki doesn't seem like it, it's just calling $c->render
19:01 ashimema joined #mojo
19:07 Grinnz maybe something is closing over $self
19:07 Grinnz and creating a cycle?
19:15 rick_soc Let's try this again - anybody have recommendations of implementing Roles/privileges in mojo
19:19 Grinnz rick_soc: it doesn't sound like anything mojo-specific to me. I assign groups (roles) to users in a database table, and then based on the groups they have certain privileges, it's all pretty straightforward
19:20 chandwki well, I don't know if there is an out of the box solution to do that, sounds like something you would have to write
19:20 Grinnz how much you want to flesh it out or optimize it is up to you
19:21 sri the topic comes up a lot, but so far nobody volunteered to write a good auth plugin with roles and different auth mechanisms
19:22 chandwki I think it is usually pretty application specific, I guess you could write a generic plugin to handle most cases
19:23 sri have hooks for db integration and auth modules for openid, oauth, basic...
19:23 sri it's not very complicated
19:25 chandwki they way I have done it in the past (for an API) is I have the concept of a group that you can assign to a user. A group has an array of permission objects. Each permission consists of a "space" with read, create, update, and delete flags. All of that is represented in a data model that merges all of those permissions in to a hash. Then for a GET action in a controller you can check if the user has read permissions for that spa
19:27 rick_soc Right, that was my conclusion too, to populate a hash and check that on each resource load
19:27 rick_soc It's the loading of the hash each time I'm wary on, since I'd have to requery and build it every request
19:28 chandwki computers are pretty darn fast XD
19:28 chandwki but you could memcache it
19:28 chandwki and then clear the cache every time the user is added or removed from a group
19:29 rick_soc it would still be better than some of the other php solutions I've seen where every partial resource being used to build the page has multiple if statements to check authorization 8-o
19:30 rick_soc sri:  I came across this last night:  https://metacpan.org/pod/Mojolicious::Plugin::SimpleAuthorization
19:31 irqq_ joined #mojo
19:31 rick_soc And then here is another:  https://metacpan.org/pod/release/BYTEROCK/Mojolicious-Plugin-Authorization-1.03/lib/Mojolicious/Plugin/Authorization.pm
19:31 rick_soc Which does it in a completely different way
19:32 sri i tend to use roles like tags applied to users, every user can have multiple roles and then there's a route condition checking routes "my $admin = $public->under('/' => {role => 'admin'})->to('Auth::OpenID#check')" and for links and stuff on templates a helper "% if (current_user_has_roles 'admin', 'something-else') {"
19:35 sri s/condition/condition or plain under with auth controller/
19:37 skippydippy joined #mojo
19:38 itaipu joined #mojo
19:48 mib_oeht8m joined #mojo
19:57 bianca joined #mojo
20:42 [vlad] http://www.bbc.com/news/world-us-canada-40817253
20:42 [vlad] whoops wrong network sorry
21:21 itaipu joined #mojo
22:25 VVelox joined #mojo
23:51 stryx` joined #mojo

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