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

IRC log for #mojo, 2017-12-10

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

All times shown according to UTC.

Time Nick Message
00:09 marty joined #mojo
00:14 jberger sri: do restrictive placeholders prevent routing based on the format query parameters and accept headers too?
00:14 jberger or are those just for file extensions
00:16 marty_ joined #mojo
00:16 jberger hmmm, it seems to then require file extension based negotiation
00:21 jberger I guess that makes sense
00:26 jberger I think I'll skip that bit in here :-P
02:10 gizmomathboy joined #mojo
03:00 ilbot2 joined #mojo
03:00 Topic for #mojo is now 🍩 nom nom | http://mojolicious.org | http://irclog.mojolicious.org | http://code-of-conduct.mojolicious.org
05:58 jberger Day 10! https://twitter.com/joelaberger/status/939735977471430656
06:39 kaare_ joined #mojo
06:47 khedin joined #mojo
07:04 Vandal joined #mojo
08:45 dod joined #mojo
08:52 dod joined #mojo
09:03 geospeck joined #mojo
09:47 coolo jberger: lovin it!
09:51 sh14 joined #mojo
11:35 trone joined #mojo
12:26 cosimo joined #mojo
12:54 berov joined #mojo
13:44 CandyAngel jberger: day 10 s/varity/variety/
13:50 sri jberger: app->renderer->default_value('json');
13:50 sri think you mean default_format
13:54 CandyAngel I'll add it to my PR
13:56 CandyAngel jberger: Send a PR for Day 10 fixes
13:56 CandyAngel Sent even
13:56 CandyAngel yay for typos!
14:59 geospeck joined #mojo
15:00 geospeck joined #mojo
15:01 geospeck joined #mojo
15:02 geospeck joined #mojo
15:17 dod joined #mojo
15:36 sri damn, the minion release yesterday was full of bugs :S
15:36 sri didn't even realize that active_locks in stats can't work
15:41 CHYC joined #mojo
15:43 jberger CandyAngel += 2
15:43 CandyAngel :D
15:43 jberger sri++
15:43 jberger also it gave me a good way to tweet about it again this morning
15:43 jberger https://twitter.com/joelaberger/status/939883092147408897
15:50 good_news_everyon joined #mojo
15:50 good_news_everyon [minion] kraih pushed 1 new commit to master: https://git.io/vbRYX
15:50 good_news_everyon minion/master 1c5fb5f Sebastian Riedel: fix multiple bugs in Minion::Backend::Pg related to the minion_locks table only deleting expired locks when a new lock is requested
15:50 good_news_everyon left #mojo
15:51 good_news_everyon joined #mojo
15:51 good_news_everyon [minion] kraih pushed 1 new commit to master: https://git.io/vbRY1
15:51 good_news_everyon minion/master 9b15320 Sebastian Riedel: add a new partial template
15:51 good_news_everyon left #mojo
15:51 geospeck joined #mojo
15:51 sri Grinnz: good thing you didn't add that stuff yet :)
15:52 sri then again, maybe you would have found it and prevented me from releasing
15:55 good_news_everyon joined #mojo
15:55 good_news_everyon [minion] kraih tagged v8.05 at 6b2c40c: https://git.io/vbRY5
15:55 good_news_everyon left #mojo
16:00 Armen joined #mojo
16:16 karjala_ joined #mojo
16:21 CandyAngel On a scale of 1-10, how bad is this: my $role = (state $role_for = {1 => '+Foo', 2 => '+Bar'})->{$type};
16:39 CHYC joined #mojo
16:50 cascardo joined #mojo
16:52 geospeck joined #mojo
16:58 geospeck joined #mojo
17:00 CandyAngel Packet parser using roles seems to do about 23K/second
17:00 CandyAngel I think that will be plenty fast enough :D
17:01 jberger nice
17:01 jberger and btw, that's a neat pattern for a simple hash lookup
17:04 mohawk yes, that should probably make it into a perldoc
17:04 mohawk although the venerable module lexical can have its place too ;-)
17:08 CandyAngel Aw, I can't use ->does with relative role names
17:09 mohawk (is "does" the right one? i thought it was "DOES"?)
17:09 mohawk i can never remember
17:10 CandyAngel Role::Tiny method call is 'does_role' and 'does'
17:10 CandyAngel But it needs a full package name
17:11 pink_mist DOES seems more like perl 6
17:12 CandyAngel Hmm.. I can see a way of making a does that allows relative role names, seeing as the base class is still in the class name
17:13 jberger Mojo::Base could overload does
17:14 CandyAngel Yup, that's what I was thinking
17:15 jberger I guess it is harder than I was thinking
17:16 jberger though perhaps you avoid most of it if you just make the same rules as with_roles
17:16 CandyAngel Seems like it should really be part of Role::Tiny though
17:16 jberger Role::Tiny doesn't have a concept of relative role names
17:17 CandyAngel yeah, same rules as with_roles
17:17 CandyAngel Need to prefix with + for "relative to"
17:17 jberger but what about roles composed into objects?
17:17 ChmEarl joined #mojo
17:17 jberger those get a new class composed at runtime
17:18 jberger you'd probably have to walk the mro to make those work
17:18 CandyAngel yeah, but the class name has the base class in it, doesn't it?
17:18 jberger I don't know, even if it is in it, it wouldn't be the entire name
17:18 CandyAngel BaseClass__WITH__BaseClass::Role::Foo
17:19 jberger overall I think it is probably good practice to just use the full role name
17:19 jberger I can come up with several other cases that wouldn't work
17:19 CandyAngel It might depend how it is constructed, but that is the class name I see in my packet parser
17:20 mohawk i think going with full role name is best
17:20 CandyAngel I can add it as a method in my base class if it is particular to how I am using roles
17:20 jberger I suspect haarg would tell you not to depend on the generated name
17:20 haarg ^
17:21 CandyAngel Okay, I need to add a method into every role saying what type of packet it is then
17:25 mohawk that sounds like an introspection capability which i am a huge fan of
17:25 mohawk (as i just commented on an EUMM issue)
17:25 mohawk i am going to be a bit awkward (sorry) and question whether roles are the right solution here
17:25 CandyAngel Not awkward at all.. asking that myself :P
17:26 CandyAngel I mean, the code is actually super tidy, so I really like that
17:26 mohawk reminds me a bit of a perlmonks thread i saw where someone described how to do a Finite State Machine with roles (the example was of a door that can be open or closed)
17:26 mohawk well, tidy is good
17:26 CandyAngel And should make encoding packets easy and tidy too
17:27 mohawk my thought here was to have a lookup table from name to a decoding coderef
17:27 CandyAngel Yeah, I've got a version that does that (and an encoding one)
17:27 mohawk my thought with roles is that you might be generating a class each call, though i also assume Role::Tiny will cache so maybe not
17:27 mohawk have you performance-tested the lookup version?
17:28 mohawk sometimes OO is not the truly easy way to do things
17:28 mohawk and roles solve some of the problems with OO, but not that one :-)
17:28 CandyAngel :P
17:28 CandyAngel No, i haven't done performance testing on that one
17:29 mohawk sometimes OO is a great way to encapsulate and conceal info, but sometimes just functions are also a real cool hand
17:29 CandyAngel I've gone from having encode/decode functions that take/return hashes of data, to this role thing which has nice interface :P
17:30 mohawk it's your trainset ;-)
17:30 CandyAngel ^_^
17:30 mohawk what if your decoders could live as data, eg in a YAML file
17:30 mohawk (including using the recently-fixed single-line subs capability)
17:30 mohawk data should be king, code should be a tragic necessity in an imperfect world
17:35 mohawk and roles are code, and therefore only the best case after other options have been considered ;-)
17:37 CandyAngel Some packets are just simple unpacks
17:37 CandyAngel But others need special handholding because of how the packets are implemented
17:37 mohawk sure
17:37 CandyAngel And any packet could be a collection packet, if it has a particular target
17:38 mohawk how special? is it just one function, ultimately?
17:38 CandyAngel Yeah, none are super complicated
17:38 mohawk code as data
17:38 mohawk (austinpowers) yeah
17:38 CandyAngel :P
17:38 mohawk there really ought to be a unicode emoji for him
17:42 CandyAngel Hm.. I could just make the base class store its name and then in  it's does method, just prefix it when '+' is given
17:43 CandyAngel Then it isn't depending on the generated package name
17:47 mohawk or, you can keep it 100% OO
17:58 mohawk sri, i'm getting mojibake from this: cpanm OpenAPI::Client; mojo openapi http://petstore.swagger.io/v2/swagger.json getInventory
17:58 mohawk a test i just added shows that (i believe) it may be in the Mojolicious::Command stuff
17:58 mohawk want me to investigate/PR?
18:11 mohawk looks like it's re-utf-8-encoding the JSON without first decoding it, which is sort of what you'd expect with that output
18:19 mohawk ok, so cancel my last, this has no mojibake: mojo get http://petstore.swagger.io/v2/store/inventory
18:46 Grinnz sri: actually i did :s i wasn't paying enough attention i guess, i dont use locks yet
18:48 Grinnz CandyAngel: a constant provided by the role saying the packet type sounds perfectly reasonable to me
18:48 geospeck joined #mojo
18:50 Grinnz CandyAngel: though actually i'm not sure if i'm following your structure here, i would have expected a role as the abstraction of a packet and each packet type to be a class composing that role
18:50 CandyAngel Grinnz: That is how it is.. I think
18:51 CandyAngel Right now, I have Packet class with a parse method, which parses the header, then does: return $self->with_roles($type_role)->parse_payload
18:52 Grinnz thats kinda backwards from what i said :P
18:52 CandyAngel Ah
18:52 CandyAngel I.. don't follow roles
18:52 CandyAngel Which you probably guessed
18:52 Grinnz but that works too, you're just using roles as an application of functionality
18:52 rickbol joined #mojo
18:52 * CandyAngel doesn't know the terminology
18:53 CandyAngel I'm super not tied to doing it this way. Definitely open to suggestions :D
18:54 Grinnz well the way i was thinking of is that you just have one Packet role, which provides common methodology/attributes, and then each packet type has a class that composes that role so they all 'do' packet parsing, etc
18:54 mohawk it does sound to me like packet types are legitimate subclasses
18:54 mohawk is this really a "roles" situation?
18:55 Grinnz it's always a roles situation ;)
18:55 mohawk le sigh
18:55 CandyAngel Grinnz: I don't see how that is different to just having subclasses
18:56 Grinnz it's different because you don't need to mess with inheritence
18:56 mohawk i suggest that the bestest way here is just have packets be a hash with keys "type" and "data"
18:57 mohawk the "type" is used to lookup a decoder
18:57 mohawk if you must go OO, then each packet should be an object that "isa" Packet, but is a subclass
18:57 mohawk i cannot see a reason to have roles in this picture
18:57 CandyAngel mohawk: Yeah, I have an implementation like that
18:57 mohawk i am probably missing something!
18:58 mohawk CandyAngel, i was taught by a very very good engineer that you don't always have to add code to make things better
18:58 mohawk the true zen of software maintenance is to delete code
18:59 Grinnz i would just say do whatever is easiest to reason about and maintain
19:00 CandyAngel This is really "supposed to be" the public facing bit of this, but someone might to use this packet parsing with a different  server
19:00 CandyAngel isn't really*
19:00 CandyAngel might want*.. argh, typing
19:02 CandyAngel I should stop worrying about it, really :P
19:02 CandyAngel Really appreciate the discussion though!
19:03 Grinnz with your current method, i would still write a 'common' role that enforces the interface you want to compose into your packets
19:04 Grinnz like the parsing method you expect to call, the packet type constant if you're doing that, etc
19:04 CandyAngel You mean the 'requires' thing?
19:04 Grinnz yes
19:06 mohawk a role that's actually an interface
19:10 Grinnz roles are interfaces
19:10 mohawk i was thinking of java-style interfaces
19:10 Grinnz exactly
19:10 mohawk it's definitely a word with many meanings ;-)
19:11 mohawk a role without any "requires" isn't an interface in that sense?
19:11 Grinnz they provide guarantees that what they're composed into "does" certain things, either because the role provided the implementation or required that the composee did
19:12 Grinnz i don't think composee is actually correct but i'm using it anyway
19:12 mohawk you could say the same thing about a class
19:13 mohawk it seems to me you're using it in a way that's general enough to not be meaningful? to me, at least
19:13 Grinnz you can always use classes the same way, you just end up with bonkers multiple inheritence
19:13 Grinnz and there's no compile time enforcement of methods existing
19:13 Grinnz compose time, i should say
19:14 Grinnz the java ones are via inheritence right?
19:15 Grinnz i dunno, its been forever since i did any java
19:16 mohawk i last did java in 2000
19:16 Grinnz haha, maybe 2006 for me
19:16 mohawk the java ones are only and entirely an enforcement that an implementor will provide given methods (and maybe attributes, would have to look)
19:17 mohawk they cannot contain code
19:17 CandyAngel Time for me to head home. Back later.. hopefully :|
19:17 Grinnz right, i had a feeling they were more specific
19:18 Grinnz roles being able to provide implementations seems more useful to me, though
19:18 Grinnz but java is super structured like that
19:18 mohawk indeed
19:19 mohawk so a java-style interface can be made with a role that just has "requires" and nothing else
19:20 Grinnz https://metacpan.org/source/DBOOK/WWW-OAuth-0.006/lib/WWW/OAuth/Request.pm this is basically an interface, except i define 'default' implementations for two of the methods
19:21 mohawk yes it is :-)
19:21 Grinnz without being able to do that id just have to copy paste those to a couple more classes
19:22 mohawk in java-land you'd have to make a partially-abstract base class
19:22 mohawk not sure whether that could implement an interface, i'm guessing yes
19:22 Grinnz yeah just another layer
19:26 mohawk so in java-land you can indeed make the interface, and then an abstract class that partially implements it. that would give you the option of extending that to get the defaults, or doing your own thing just by implementing the interface your way. https://hackerbits.com/programming/why-does-an-abstract-class-need-to-implement-interface-methods/
19:27 mohawk and a consumer would just say it wants something implementing the interface
19:28 jonasbn joined #mojo
19:32 jonasbn marcus: just got a notification from the mojo-classes project on Github
19:32 jonasbn marcus: you can archive the project, ref: https://help.github.com/articles/archiving-repositories/
20:24 Grinnz sri: would `(select count(*) from minion_locks where expires > now()) as active_locks` not be efficient?
20:25 Grinnz it would use the index no?
20:26 Grinnz ohh, the index is by name
20:27 Grinnz that would mean `delete from minion_locks where expires < now();` in the stored procedure doesn't have an index to use either though
20:27 Grinnz maybe an index should be added?
20:38 sri Grinnz: maybe, maybe not, don't have time for profiling at the moment
20:44 sri Grinnz: why is this not just a state $ndn there? https://github.com/kraih/mojo/pull/1161/files#diff-4b4175417080883ed2af6e92086dc8f2R48
20:44 Grinnz that could work too, I never really use state so didn't think of it
20:45 Grinnz well the problem is, $NDN is used in another function
20:45 sri ah, cleanup
20:45 sri so, what do we gain from the change?
20:45 sri memory usage?
20:48 sri on macos it doesn't appear to make a difference
20:48 Grinnz i don't think the thread pool uses a significant amount of memory when it's not used, no
20:48 sri neither startup time nor memory usage
20:48 sri so, why should we make the change?
20:49 sri batman: you voted +1, why?
20:49 Grinnz less points of failure for applications that have no need for the thread pool
20:50 sri or fail later, harder to debug
20:50 sri jberger: easy win of what?
20:52 Grinnz personally, it's a huge mess in htop when i have 8 workers with 5 unused threads each, but thats just my motivation
20:55 good_news_everyon joined #mojo
20:55 good_news_everyon [mojo] kraih pushed 2 new commits to master: https://git.io/vbRul
20:55 good_news_everyon mojo/master 13deb03 Dan Book: only spawn Net::DNS::Native threads if Mojo::IOLoop::Client is used
20:55 good_news_everyon mojo/master 826ab5b Sebastian Riedel: Merge pull request #1161 from Grinnz/lazy_ndn...
20:55 good_news_everyon left #mojo
21:01 good_news_everyon joined #mojo
21:01 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vbRu1
21:01 good_news_everyon mojo/master 6341094 Sebastian Riedel: update Changes
21:01 good_news_everyon left #mojo
21:07 Grinnz actually if you call list_locks without providing a name, you have the same problem with not being able to use an index
21:07 Grinnz it probably only would matter once you have a lot of locks
21:09 Grinnz well especially if you had a lot of locks that weren't cleaned up yet by a call to lock
21:10 Grinnz expired locks
21:33 sri Grinnz: list_locks is not required to be fast, it's purpose is debugging
21:33 Grinnz yeah but in that case, the call to lock will also be slow when it runs that delete
22:00 sri patches with benchmarks welcome
22:13 sri i think the index that's there works for postgres though
22:20 noganex_ joined #mojo
22:58 CandyAngel Got home safely
23:09 berov1 joined #mojo
23:17 good_news_everyon joined #mojo
23:17 good_news_everyon [minion] kraih pushed 1 new commit to master: https://git.io/vbRoM
23:17 good_news_everyon minion/master 9c5d94d Sebastian Riedel: allow for locks to be managed from the admin ui
23:17 good_news_everyon left #mojo
23:19 sri unspectacular but useful https://i.imgur.com/uH1Z5Ml.png
23:19 mohawk noice
23:24 good_news_everyon joined #mojo
23:24 good_news_everyon [minion] kraih tagged v8.06 at 6f5cbfc: https://git.io/vbRKJ
23:24 good_news_everyon left #mojo
23:57 kiwiroy joined #mojo

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