diff options
| author | franck cuny <franck@lumberjaph.net> | 2010-05-13 14:52:10 +0200 |
|---|---|---|
| committer | franck cuny <franck@lumberjaph.net> | 2010-05-13 14:52:10 +0200 |
| commit | 63878b82e21a9b7077e36186f3c70035c60deb64 (patch) | |
| tree | 33c3851df5781dc50588d312607475798350af53 /lib | |
| parent | regenerate README (diff) | |
| download | presque-63878b82e21a9b7077e36186f3c70035c60deb64.tar.gz | |
add worker handler, method to load handler
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/presque.pm | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/lib/presque.pm b/lib/presque.pm index 69998d6..744dc3f 100644 --- a/lib/presque.pm +++ b/lib/presque.pm @@ -1,23 +1,12 @@ package presque; -use Moose; our $VERSION = '0.01'; -extends 'Tatsumaki::Application'; use AnyEvent::Redis; +use Moose; +extends 'Tatsumaki::Application'; -use presque::RestQueueHandler; -use presque::JobQueueHandler; -use presque::IndexHandler; -use presque::StatusHandler; -use presque::ControlHandler; - -has config => ( - is => 'rw', - isa => 'HashRef', - lazy => 1, - default => sub { } -); +has config => (is => 'rw', isa => 'HashRef', lazy => 1, default => sub { }); has redis => ( is => 'rw', @@ -32,17 +21,25 @@ has redis => ( } ); +sub h { + my $class = shift; + eval "require $class" or die $@; + $class; +} + sub app { - my ( $class, %args ) = @_; - my $self = $class->new( [ - '/q/(.*)' => 'presque::RestQueueHandler', - '/j/(.*)' => 'presque::JobQueueHandler', - '/stats/(.*)' => 'presque::StatusHandler', - '/control/(.*)' => 'presque::ControlHandler', - '/' => 'presque::IndexHandler', + my ($class, %args) = @_; + my $self = $class->new( + [ '/q/(.*)' => h('presque::RestQueueHandler'), + '/j/(.*)' => h('presque::JobQueueHandler'), + '/w/(.*)' => h('presque::WorkerHandler'), + '/stats/(.*)' => h('presque::StatusHandler'), + '/control/(.*)' => h('presque::ControlHandler'), + '/' => h('presque::IndexHandler'), ] ); - $self->config( delete $args{config} ); + + $self->config(delete $args{config}); $self; } @@ -59,8 +56,7 @@ presque - a redis based message queue presque is a message queue system based on Tatsumaki and Redis. -It's functionality are inspired by L<RestMQ|http://github.com/gleicon/restmq> -and the name by L<resque|http://github.com/defunkt/resque>. +The functionalities are inspired by L<RestMQ|http://github.com/gleicon/restmq> and the name by L<resque|http://github.com/defunkt/resque>. The following HTTP routes are available: |
