diff options
Diffstat (limited to '')
| -rw-r--r-- | posts/2010-09-10-dancer-summer-of-code.org | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/posts/2010-09-10-dancer-summer-of-code.org b/posts/2010-09-10-dancer-summer-of-code.org new file mode 100644 index 0000000..7527f8f --- /dev/null +++ b/posts/2010-09-10-dancer-summer-of-code.org @@ -0,0 +1,170 @@ +*** Middleware + +After the [[http://journeesperl.fr/fpw2010/][French Perl Workshop]], we +decided to focus our efforts on bringing middleware into Dancer. As the +.psgi script is now obsolete, we wanted to simplify the middleware +configuration for users not familiar with Plack. + +It's now possible to load a middleware by adding it to your +configuration: + +#+BEGIN_EXAMPLE + plack_middlewares: + Debug: + - panels + - + - DBITrace + - Memory + - Timer +#+END_EXAMPLE + +*** YAPC::Eu 2010 + +During YAPC::EU, I've been happy to meet with +[[http://github.com/squeeks][squeeks]], +[[http://blogs.perl.org/users/sawyer_x/][sawyer]] and +[[http://github.com/mberends][Martin Berends]]. Sadly, we didn't have +much time to talk and do some coding. + +I had already met Martin during the FPW, where he started to port Dancer +to Perl6. His first objective is to have +[[http://github.com/mberends/http-server-simple][HTTP::Server::Simple]] +work. I was really impressed with his works; if I manage to find some +spare time soon, I will join his effort. + +*** Dancer's application + +In august, [[http://www.sukria.net/][Alexis]] brought a big effort to +refactor the core of Dancer, to add the possibility to "plug" components +to your application. This required a lot of rewriting, but in the +meantime, we added more tests to ensure nothing would break. + +With this feature, you can do the following: + +#+BEGIN_SRC perl + package myapp::forum; + use Dancer ':syntax'; + + before => sub { + ... + }; + + get '/' => sub { + ... + }; + + package myapp:blog; + use Dancer ':syntax'; + + load_app 'myapp::forum', prefix => '/forum'; + + before => sub { + ... + }; + + get '/' => sub { + ... + }; +#+END_SRC + +Now you can request */* and */forum*. The before filter declared in the +package *myapp::forum* will be executed when the */forum* path is +matched, and the filter in *myapp::blog* will be executed for */*. + +*** QA + +The weekend following the YAPC::EU, we held a small hackaton/QA day on +irc. Not many people were present, but we managed to achieve some +results: + +- reached the 1K tests +- documentation cleanup +- added Hooks +- improved our code coverage + +Today our code average is over 92%, and we have more than 1200 tests. + +With the new hook system, two new keywords have been added: +*before\_template* and *after*. They work as the *before* keyword, +except the *before\_template* is executed before sending the tokens to +the template, so you can modify them (a small example can be found in +the +[[http://git.lumberjaph.net/p5-dancer-plugin-18n.git/][Dancer::Plugin::i18n]]). +The *after* is executed before the response is sent to the user. + +Sukria has also set up an autobuild system for our two main branches. +Every 15 minutes, the test suite is executed when there is a new commit, +and builds a report. Code coverage is also measured, so we can always +know the state of our various development cycles. + +*** WebSocket + +This is the question that came back from time to time: when/will Dancer +support websocket ? + +We investigated various ways to do this: + +- new async. handler +- writing our own implementation +- ... + +I didn't want to write a websocket implementation for Dancer, as the +spec are not yet final and it's not easy to do. Thanks to +[[http://github.com/clkao][clkao]], we didn't have to care about all +this, as he already wrote a Plack middleware for this: +[[http://search.cpan.org/perldoc?Web::Hippie::Pipe][Web::Hippie]]. + +So, what we did, is to use this middleware and add some syntactic sugar +so people can use it easily in their applications. A small application +is available [[http://git.lumberjaph.net/p5-dancer-chat.git/][here]]. + +This is not yet complete, it's only available in the 'devel' branch, and +subject to change. A small code sample: + +#+BEGIN_SRC perl + websocket '/new_listener' => sub { + my $env = request->env; + my $room = $env->{'hippie.args'}; + my $topic = $env->{'hippie.bus'}->topic($room); + $env->{'hippie.listener'}->subscribe($topic); + }; + + websocket '/message' => sub { + my $env = request->env; + my $room = $env->{'hippie.args'}; + my $topic = $env->{'hippie.bus'}->topic($room); + + my $msg = $env->{'hippie.message'}; + $msg->{time} = time; + $msg->{address} = $env->{REMOTE_ADDR}; + $topic->publish($msg); + }; +#+END_SRC + +As you can see, a lot of stuff can be improved quite easily in terms of +syntax. + +*** Deployment + +We're also in the process of reworking our current Deployment +documentation. Lots of people are trying to deploy Dancer using various +configurations, and not all are well documented, or don't work as +expected. If you use Dancer, and have deployed an application in a way +not documened in our Deployement documentation, please join us on irc +(#dancer on irc.perl.org) or contact us on the mailing list, or even +better, send us a patch, so we can improve this part. + +*** Future + +There is also our next Dancer's meeting meeting to organize, at the end +of Septembre. + +In October will take place the 2nd OSDC.fr, where I will talk about +Plack, and alexis will present Dancer. + +I want to thank my company ([[http://linkfluence.net][Linkfluence]]) and +my boss ([[http://twitter.com/cmaussan][Camille]]) for giving me time to +code on Dancer at work. + +As always, thanks to blob for reviewing my (slightly improving) english +:) |
