diff --git a/lib/Lacuna.pm b/lib/Lacuna.pm index 8dc4b445..d30a2946 100644 --- a/lib/Lacuna.pm +++ b/lib/Lacuna.pm @@ -7,16 +7,17 @@ use Config::JSON; useall __PACKAGE__; -our $VERSION = 3.0875; +our $VERSION = 3.0874; my $config = Config::JSON->new('/data/Lacuna-Server/etc/lacuna.conf'); my $db = Lacuna::DB->connect($config->get('db/dsn'),$config->get('db/username'),$config->get('db/password'), { mysql_enable_utf8 => 1}); my $cache = Lacuna::Cache->new(servers => $config->get('memcached')); -#use IO::File; -# $db->storage->debug(1); -# $db->storage->debugfh(IO::File->new('/tmp/dbic.trace.out', 'w')); - +my $queue = Lacuna::Queue->new({ + server => $config->get('beanstalk/server'), + ttr => $config->get('beanstalk/ttr'), + debug => $config->get('beanstalk/debug'), +}); sub version { return $VERSION; @@ -34,5 +35,8 @@ sub cache { return $cache; } +sub queue { + return $queue; +} 1; diff --git a/lib/Lacuna/Queue.pm b/lib/Lacuna/Queue.pm index 00b768f8..4e81549a 100644 --- a/lib/Lacuna/Queue.pm +++ b/lib/Lacuna/Queue.pm @@ -84,15 +84,24 @@ sub peek { return; } +sub delete { + my ($self, $job_id) = @_; + + my $beanstalk = $self->_beanstalk; + + $beanstalk->delete($job_id); + return; +} + + # DRY Principle my $meta = __PACKAGE__->meta; foreach my $proc (qw(peek_buried peek_ready peek_delayed)) { $meta->add_method($proc => sub { - my ($self) = @_; + my ($self) = @_; - my $beanstalk = $self->_beanstalk; - my $job = $beanstalk->$proc; + my $job = $self->_beanstalk->$proc; if ($job) { return Lacuna::Queue::Job->new({job => $job}); }