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

IRC log for #mojo, 2016-04-15

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

All times shown according to UTC.

Time Nick Message
00:18 bpmedley new_student: https://gist.github.com/brianmed/a8e2b2673f9a9bc587279f8bf67e89f3
00:21 new_student bpmedley: how would you change this, when there are more than one TCP calls to be made
00:22 new_student s/TCP calls/transactions over wire
00:22 bpmedley new_student: How many TCP transactions?
00:23 sri bpmedley: you're rendering whenever new data arrives
00:23 sri that doesn't work
00:23 new_student depends on the route, but in my case, I have upto 23 subs in the sequence in which at least 7 or 8 are TCP transactions (not at the border, somewhere in between, with non-tcp transactions in between)
00:23 bpmedley echo Joy | nc -l 127.0.0.1 4000  <-- Here is my server on 4000..
00:24 new_student it's like NB, NB, B, NB, B, B , NB, B, B, B, NB, NB, NB, B, NB
00:24 bpmedley Wowzers, let me think.
00:25 bpmedley sri: Given the trivial nature of my example, will the render work?
00:25 new_student B is blocking and NB is non blocking
00:25 mattp_ sri: why? im confused
00:25 bpmedley new_student: I'd use one of the fork helpers that either jberger or batman wrote..
00:26 sri bpmedley: the render should work for the first chunk
00:26 sri honestly, i have no idea what the followup render calls do
00:26 sri they might end up breaking stuff
00:26 new_student yes, render would work only for the first chunk
00:26 bpmedley sri: I guess technically I could just get a "J" as the first chunk of data?
00:27 mattp_ sri: write() instead of render() if multiple reads() are done before EOF?
00:27 new_student but how is chunk defined here?
00:27 sri mattp_: not relevant
00:28 sri point is you should be buffering input, and then try to parse it whenever new data gets appended, until you've received all data you were waiting for
00:28 mattp_ ah
00:28 sri if it's a custom tcp protocol, abstract it out into your own client
00:29 bpmedley sri: I hear what you're saying, my bad..
00:29 new_student custom tcp? who wants to modify tcp ? :P
00:30 new_student or you meant custom protocol over tcp
00:30 bpmedley new_student: Given that you have so many transactions, would you consider one of the Fork plugins?
00:30 new_student bpmedley: point me towards them
00:30 sri and i'm out
00:31 new_student sri doesn't like forks?
00:31 bpmedley new_student: https://metacpan.org/pod/Mojolicious::Plugin::ForkCall
00:32 sri no, term lawyering
00:32 jberger ForkCall isn't good for intermediate actions
00:33 bpmedley jberger: How can this be solved elegantly?
00:33 jberger it is a fire and get the results asynchronously
00:33 jberger ReadWriteFork emits an event on read
00:33 jberger I haven't been following the conversation too closely
00:33 jberger we have Chicago.pm now
00:34 new_student what's Chicago.pm
00:34 bpmedley I'm somewhat clueless on how to do multiple TCP transactions via delay, or somesuch.
00:34 jberger I'd look at a concise example
00:34 jberger new_student: Perl Mongers groups are like Linux Users Groups for Perl
00:34 jberger Perl Mongers gets shortened to pm
00:34 jberger http://chicago.pm.org
00:35 jberger also pm.org
00:35 new_student Oh. Meetups
00:40 bpmedley new_student: Do you have a plan for an approach, or is more banter required?
00:41 jberger new_student: could you make even a pseudocode example?
00:42 new_student well, to be honest, I don't have any plan. Whatever I had working required the use of a different design, wherein I had single route for each intermediate transaction and an aggregator written in nodejs.
00:42 new_student I just wanted to remove nodejs from the picture and got into this situation
00:42 jberger are there lots of different steps or is there one long step that you want to report progress on?
00:43 bpmedley new_student: Let me put together an example that I'm thinking about, ok?
00:43 jberger sure
00:43 bpmedley jberger: As many ~20 steps, iirc
00:43 jberger and what takes a long time about these steps?
00:43 new_student jberger: I don't want to report progress on anything. The end user only cares about the end result.
00:43 new_student The only thing is, if I throw 100 inputs at once
00:44 new_student the current design scales very poorly
00:44 new_student whereas the earlier designed scaled nicely
00:44 jberger could you use a job queue?
00:44 bpmedley jberger: My understanding is that they are mostly TCP transactions..
00:44 bpmedley Hrmm, that'd be better..
00:44 jberger Mojolicious has a companion project called minion
00:45 jberger which is a job queue
00:45 new_student that's a nice idea I guess
00:46 new_student I will have to look into how best I can implement it though
00:46 jberger ForkCall might also work for you
00:46 jberger I'd just have to see what you are working on
00:47 jberger is this really TCP or is it really HTTP?
00:47 new_student TCP
00:47 jberger so this isn't a webapp
00:47 new_student well, if you want to see a monolith, it is present right here:  https://github.com/ltrc/ilparser-api
00:48 tchaves joined #mojo
00:48 new_student TCP is used only for calling the internal services
00:48 new_student which are running independantly of the main perl program
00:50 jberger that is really too much to try to grok at this moment
00:50 bpmedley new_student: https://gist.github.com/brianmed/a8e2b2673f9a9bc587279f8bf67e89f3 <-- Via ForkCall
00:51 bpmedley new_student: Do you see how you can chain your TCP calls in the fork_call?
00:52 jberger bpmedley: Mojo::IOLoop->client can be used rather than IO::Socket::INET, if you want
00:52 new_student Well, it's 6AM here. Need some sleep. I'll catch up with you later. Thank you for your code snippets, bpmedley I'll look into minion and fork_call when I wake up.
00:52 bpmedley I agree; how can IOLoop->client be made easy to read with 10-20 transactions?
00:52 jberger new_student: good luck
00:52 jberger sleep well!
00:53 new_student :)
00:57 asarch joined #mojo
01:37 jberger sri: ok there's still one thing I don't understand about expand
01:38 jberger why do you convert each item individually? https://github.com/kraih/mojo-pg/blob/master/lib/Mojo/Pg/Results.pm#L56
01:38 jberger when you are looping over @data
01:38 jberger it seems like you could just do the each $data as a whole?
01:42 jasanj joined #mojo
01:46 thowe I have a minor issue, and I have some ideas for solving it, but I want to run it by here cause I'm sure it has a common solution...
01:46 thowe I have some parts of pages that load bits of html via ajax-y whatever...
01:46 thowe But I have a root route that checks for being logged in..  This means if you sit on a page for a while, session timeout, and click something to load a bit of page, you may get a login page instead of the ajaxy-y bit in that div or whatever.
01:46 jasanj batman: the document is clear now
01:46 jasanj thanks
01:46 jberger or actually, sri, why are you using @data rather than just the first argument directly?
01:47 ilbot2 joined #mojo
01:47 Topic for #mojo is now 🍻 cheers | http://mojolicious.org | http://irclog.mojolicious.org | http://code-of-conduct.mojolicious.org
01:47 thowe so, I'm wondering if I should load pages with a timer to pre-emptively log you out to prevent this?  Or maybe have some function that can be checked by the ajax before loading the page bits?  Anyhoo, you're in the middle of something else, so I'll maybe ask more concisely later
01:48 bpmedley http://mojolicious.org/perldoc/Mojo/Message/Request#is_xhr  <-- will this help?
01:49 thowe bpmedley, you talkin to me?
01:50 bpmedley thowe: yes
01:50 thowe lemme look...
01:51 thowe bpmedley, ah, so the idea being that if this is an ajax request, I could handle differently than just redirect to login?
01:51 bpmedley Yes, i believe so
01:52 woz joined #mojo
01:52 thowe Actually, yeah, that might be something to try...  Certainly is easier than trying to come up with a more complicated javascript solution...  I'll have to test that.  Thanks! =)
01:52 thowe bpmedley++
01:55 sri jberger: if you can optimize it please go ahead! :)
02:09 tchaves1 joined #mojo
02:17 Grinnz_ joined #mojo
02:29 Crisewng joined #mojo
02:40 noganex joined #mojo
02:55 Grinnz joined #mojo
02:56 jberger sri: interestingly I'm starting to think that you can just select the boolean column as ::json and it will already DTRT
02:57 jberger I figured that out by breaking the test at t/database.t line 143
02:57 sri sure
02:57 sri btw. i've just added a few more tests
02:57 jberger https://github.com/kraih/mojo-pg/blob/master/t/database.t#L143-L144
02:58 jberger I think this point may be moot
02:58 jberger I'm happy to just ::json that column in my query
02:59 sri so, did you find a way to optimize?
02:59 jberger I didn't get to that, but I don't see why the for loop over @data is necesary
03:01 jberger hunh
03:01 jberger but when I actually try that in my model I get:
03:01 jberger DBD::Pg::st execute failed: ERROR:  cannot cast type boolean to json
03:03 sri how odd
03:03 sri ::jsonb?
03:04 jberger nope
03:05 jberger but the postgres built-in to_json(table.column) seems to work
03:05 jberger strange that that doesn't work as a cast
03:07 jberger but then I have to alias the result ...
03:07 jberger to_json(table.column) as column
03:07 jberger grrrrr
03:21 jberger hmmm, and then I need something like unless null
03:21 jberger which I don't know how to do
03:37 iamb jberger: i was just playing in a psql client to see, does casting like to_json(table.column::text) or whatever the column type help? select to_json(null::text) is fine for me where to_json(null) fails if that's what you were running into
03:40 irqq joined #mojo
03:41 woz joined #mojo
04:06 Crisewng joined #mojo
04:11 Kripton joined #mojo
04:41 Kripton joined #mojo
04:50 Kripton joined #mojo
05:00 melo joined #mojo
05:06 sri hahaha, factorio is the weirdest game i've played in a long time, like a mix of minecraft and starcraft
05:09 Adurah joined #mojo
05:21 hrupp joined #mojo
05:23 coolo looks fun
05:29 inokenty-w joined #mojo
05:42 Guest-guest joined #mojo
05:59 Crisewng joined #mojo
06:22 batman jasanj: thank you :)
06:24 jasanj batman: i'm using RWF in my project, nice work !
06:25 batman cool, cool
06:55 new_student jberger, bpmedley I think forkcall pretty much solved the whole problem :) Running preliminary tests now. Look promising :D Yay!
07:00 osfabibisi joined #mojo
07:25 trone joined #mojo
07:31 AndrewIsh joined #mojo
07:43 berov joined #mojo
07:45 Kripton joined #mojo
07:49 Vandal joined #mojo
07:52 AndrewIsh joined #mojo
08:11 woz joined #mojo
08:13 woz joined #mojo
08:26 woz joined #mojo
08:31 csroli joined #mojo
08:47 woz joined #mojo
08:59 woz joined #mojo
09:29 woz joined #mojo
09:29 dhg joined #mojo
09:35 woz joined #mojo
09:37 woz joined #mojo
09:47 woz joined #mojo
09:53 irqq joined #mojo
09:53 woz joined #mojo
10:11 woz joined #mojo
10:12 woz joined #mojo
10:20 woz joined #mojo
10:29 woz joined #mojo
10:29 woz joined #mojo
10:36 circ-user-HH6Fu joined #mojo
10:42 melo joined #mojo
10:50 tchaves joined #mojo
10:51 anon joined #mojo
11:01 dvinciguerra joined #mojo
11:05 woz joined #mojo
11:09 go|dfish joined #mojo
11:12 woz joined #mojo
11:12 kaare_ joined #mojo
11:23 woz joined #mojo
11:33 woz joined #mojo
11:41 woz joined #mojo
11:45 csson joined #mojo
12:01 kaare joined #mojo
12:08 kaare_ joined #mojo
12:11 woz joined #mojo
12:20 woz joined #mojo
12:23 woz joined #mojo
12:37 woz joined #mojo
12:55 ivi joined #mojo
12:59 ramortegui joined #mojo
13:10 Guest-guest joined #mojo
13:19 kwa sri: The latest Minion requires at least Mojo::Pg 2.18. I was going to update Makefile.PL and do a PR, but realised that as you have different backends, you probably don't want Mojo::Pg to be a PREREQ.
13:20 kwa I'm not sure if you'd want to add the required version to the backed in use Mojo::Pg, '2.18'; or leave it to the user to figure it out if they get -- Can't locate object method "auto_migrate" via package "Mojo::Pg"
13:27 CHYC jberger: The cast from bool to json does not exist by default, but can be created
13:28 CHYC # create cast(bool as json) with function to_json(anyelement);
13:28 jberger CHYC: interesting
13:28 CHYC How useful that is compared with your solution of to_json is debatable though.
13:28 jberger Well it might be
13:29 jberger Because i want to preserve null
13:29 jberger I don't want NULL to become false
13:29 jberger And perhaps that's where the custom cast could come in
13:30 jberger Or maybe i just need a function of my own or something
13:32 CHYC jberger: to_json(NULL::bool) returns NULL for me
13:33 jberger ah, nice, my testing was wrong
13:33 jberger I didn't do the ::bool cast when I tried that last night
13:35 jberger CHYC++ # lots of good advice
13:35 CHYC jberger: Returning the favor for all the help you've given me :)
13:36 jberger I'm still behind the curve on SQL, but I'm catching up
13:38 genio it won't take long to catch up.  it's not too difficult
13:41 jberger its more like, I have to wait until I stumble onto something I don't know
13:41 jberger I guess I could read a SQL book .... but .... yawn
13:43 genio inner, outer joins.  unions.  views.  group by/having.  you can do 99% of the things with knowledge of those.  then you just have to look up what you can't remember
13:45 mcsnolte joined #mojo
13:51 perlpilot joined #mojo
13:52 kes joined #mojo
13:55 jberger "having" I still need to learn
13:55 jberger I do like CTE and group aggregations too
13:57 bpmedley jberger: you may be frustrated at having to repeat a having clause when used as a filter.. :)
14:18 kaare joined #mojo
14:22 dvinciguerra joined #mojo
14:23 jasanj_ joined #mojo
14:31 berov left #mojo
14:31 kaare_ joined #mojo
14:33 woz joined #mojo
14:38 kaare joined #mojo
14:39 asarch joined #mojo
14:51 woz joined #mojo
14:51 woz joined #mojo
15:01 sri jberger: if only there were more good books on sql
15:01 sri not sure why, but most people actually recommend super dry set theory books and the like
15:02 sri best i've read so far have actually been the postgresql docs, and the sql cookbook from oreilly
15:05 Vandal joined #mojo
15:08 Vandal joined #mojo
15:12 jberger the pg docs are really good
15:18 irqq joined #mojo
15:21 woz joined #mojo
15:24 jberger I'd really like it if you could set a preferred doc version and when google sends you to whichever pg version's docs rank highest you would still get the one you prefer
15:24 jberger I mean its nice that they have the version selector at the top, that's better than 90% of site that have this problem
15:28 Grinnz_ mysql docs have always had the same issue, but also have a selector that works well
15:29 Grinnz_ still worth using google, because the oracle search engine is atrocious
15:33 pink_mist https://www.reddit.com/r/programming/comments/4evhai/the_linux_scheduler_a_decade_of_wasted_cores
15:37 woz joined #mojo
15:48 woz joined #mojo
16:23 dvinciguerra joined #mojo
16:45 HtbaaPi joined #mojo
16:56 melo joined #mojo
17:05 Vandal joined #mojo
17:09 PryMar56 joined #mojo
17:18 gizmomathboy joined #mojo
17:20 woz joined #mojo
17:30 gizmomathboy if I have some data that I would like to be persistent but above 4KB (it's about 11KB) would using Mojolicious::Sessions::Storable be a good way to go about that, or is there something better?
17:34 trone joined #mojo
17:35 Grinnz_ ideally, use a database, keyed to some ID which you can store in the session
17:35 * sri wonders if Minion should have an auto_perform attribute
17:36 sri it would replace the $minion->perform_jobs calls with a single $minion->auto_perform(1)
17:36 sri and call $minion->perform_jobs after every $minion->enqueue(...) call
17:37 sri oh wait, there are problems
17:37 jberger seeing as perform_jobs is mostly about testing, I see the point of that but I wonder if it is limiting
17:37 jberger like if you need to set up something between those times
17:37 sri yea, your hunch is right
17:37 jberger like getting the job id
17:37 sri perform_jobs does take arguments
17:37 sri which the auto variant couldn't easily
17:38 jberger I had to actual break perform_jobs up futher the other day
17:41 sri what for?
17:42 sri not that it's a problem, quite the contrary, the docs even explain how these days
17:47 gizmomathboy Grinnz, yeah I will probably head that way, but the data is in a yaml file at the moment and being able to dump that into a stash (for now) will help me take this command line program into a web app
17:48 Grinnz_ gizmomathboy: you can dump it into a json column in postgres or sqlite
17:50 gizmomathboy Grinnz, I just started thinking how I can quickly get it to sqlite...had thought thought about the json column...might not be *too* hard to munge into sqlite. It is mostly tables from an rpg after all
17:51 Grinnz_ Mojo::SQLite has a json => converter now, like Mojo::Pg
17:51 Grinnz_ or if you want to store it as a defined structure that works too
17:52 Grinnz_ you can access json text columns in some useful ways though http://sqlite.org/json1.html
17:53 gizmomathboy Grinnz, thanks
17:54 jberger Too bad they didn't use the same function names
17:54 jberger As pg
17:55 Grinnz_ I kind of prefer that they don't imply any compatibility that might not be there
17:55 jberger That's true
17:56 gizmomathboy Mojo::SQLite looks sweet
17:56 gizmomathboy since I might as well dump my yaml file of tables into a db
17:57 gizmomathboy or at least the bulk of that file and try to trim it down to something manageable for sessions/cookies
18:05 dhg joined #mojo
18:09 csson joined #mojo
18:19 bpmedley gizmomathboy: The Mojo:: db packages are impressive
18:22 irqq joined #mojo
18:39 sri funny how all the Mojo:: db packages are a result of mojoconf
18:39 jberger as were lots of the delay improvements
18:40 bpmedley When smart ppl congregate reports happen.. ;)
18:45 new_student jberger, bpmedley I think forkcall pretty much solved the whole problem which I asked yesterday :) Yay! :D
18:45 jberger new_student: nice
18:57 batman sri: why do we protect "templates with two extensions" here https://github.com/kraih/mojo/blob/master/lib/Mojolicious/Static.pm#L129 ?
18:58 sri do you want raw templates to leak?
18:59 batman what does "raw templates" mean?
18:59 pink_mist the unrendered contents of them
18:59 batman ah, so you don't want the static plugin to render foo.html.ep ?
18:59 batman thanks
19:00 sri it doesn't render
19:00 pink_mist it's not for rendering
19:00 sri it just sends it
19:00 sri unprocessed
19:00 sri raw
19:00 batman yeah, i didn't mean *render*
19:00 batman bad choice of word :/
19:02 pink_mist new_student: what kind of service were you connecting to anyway that you needed to create a raw TCP socket?
19:04 sri hey, if anyone is interested in a commercial version of minion with more guarantees, please let me know :) https://github.com/kraih/minion/issues/32#issue-148734010
19:23 woz joined #mojo
19:26 sri oh, someone uploaded a Mojo::Role module to cpan
19:26 sri that's the kind of generic name i don't like
19:27 sri now we'll never do roles in mojo core!
19:28 sri it's really bad
19:28 sri any core role would have been in that namespace
19:28 sri Mojo::Role::IOStream or whatever
19:30 sri wait...what...jberger helped with it?
19:31 jberger we noticed after it was uploaded
19:32 jberger we worked with the author to make it something usable
19:32 jberger if we want to ask to rename the author was very receptive to our criticisms they would probably consent to that too
19:32 sri if you want to salvage it, assign the namespace to me and rename it ;p
19:33 jberger ah drat he's not on irc now :s
19:33 sri i was just trying to think of a worse name, but it's really hard
19:33 sri Mojo::HTTP2 would be worse i guess
19:33 jberger heh
19:34 jberger and I was just going to mention it in here once the fixed up one was indexed on metacpan
19:35 dvinciguerra joined #mojo
19:35 pink_mist speak of the devil :P
19:36 jberger dvinciguerra: so one more thing then
19:36 jberger sri was keeping Mojo::Role for a core module, could we coordinate to change your module's name?
19:37 jberger Mojo::RoleTiny might make sense now that yours uses Role::Tiny explicitly
19:37 sri Mojo::RoleTiny sounds sensible
19:37 pink_mist sri: better go make a placeholder dist for Mojo::HTTP2 immediately :P
19:37 sri pink_mist: hahaha
19:38 jberger you laugh but it might not be the worst idea
19:38 dvinciguerra awesome! :)
19:38 sri gotta make a list of names we were planning to use in the future ;p
19:38 jberger I was actually surprised that Mojo::Role was still available
19:38 * batman doesn't get why the module exists
19:38 batman it's such a thin layer
19:39 dvinciguerra Yes sure... can it be MojoX::Role?
19:39 dvinciguerra jberger: ^
19:40 jberger MojoX:: isn't used much anymore, but if you like that it is probably ok
19:40 sri i like Mojo::RoleTiny more, but we do not use MojoX, so that might be ok too
19:40 jberger sri, thoughts?
19:40 jberger you beat me to it
19:41 dvinciguerra Yeah! Mojo::RoleTiny is ok to me
19:44 dvinciguerra sorry me for start Mojo-Role and dont ask here first
19:44 tchaves joined #mojo
19:46 batman dvinciguerra++
19:52 sri dvinciguerra++
19:54 genio \o/ for amicably working things out!
19:56 sri sometimes i do wonder if maybe we should have kept the MojoX namespace around
19:56 sri bit late now though
19:57 jberger the MojoX:: "deprecation" was before my time (though I think just barely)
19:58 jberger what was the thinking there? just curious
19:59 sri we started out with Mojo, Mojolicious, MojoX and MojoliciousX :)
19:59 sri it was a bit much
19:59 jberger oh WE had MojoX?
19:59 sri early on Mojolicious was supposed to be even more modular
19:59 jberger as in there were core modules called MojoX?
19:59 sri yes
20:00 jberger ahhhhhh
20:00 sri we have MojoX::Renderer
20:00 sri s/have/had/
20:00 jberger I never knew why we would deprecate a contribution namespace
20:00 sri it was supposed to be a generic renderer shared by frameworks
20:00 jberger that makes a lot more sense now
20:00 sri back when mojo was meant for catalyst
20:01 sri then catalyst folks said no, and mojolicious happened
20:01 new_student pink_mist: most of them are custom NLP tools. for example. standford's POSTagger
20:01 jberger in that case I don't mind if people want to write contribution modules in MojoX:: or MojoliciousX:: then personally
20:01 jberger even if WE don't distribute modules there
20:02 jberger I like Mojo::NonControverisalName too
20:02 jberger but MojoX::ControversialName can be first-come like normal
20:02 sri yea, Mojo::* = ask #mojo, MojoX::* = do whatever
20:03 new_student pink_mist: http://nlp.stanford.edu/software/pos-tagger-faq.shtml#e see the 7th point. It listens on some pre-defined port in server mode
20:08 jacoby joined #mojo
20:16 jacoby joined #mojo
20:46 meshl joined #mojo
20:48 tchaves joined #mojo
20:53 tchaves1 joined #mojo
21:24 meshl joined #mojo
21:24 woz joined #mojo
22:27 punter joined #mojo
22:41 lluad joined #mojo
23:02 woz joined #mojo
23:03 dhg joined #mojo
23:03 lluad joined #mojo
23:15 gizmomathboy joined #mojo
23:29 meshl joined #mojo

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