Data::Model::Driver::Queue::Q4M - Q4M manager for Data::Model
use Data::Model::Driver::Queue::Q4M;
my $driver = Data::Model::Driver::Queue::Q4M->new(
dsn => 'dbi:mysql:database=test',
username => '',
password => '',
timeout => 60, # queue_wait timeout
);
{
package MyQueue;
use base 'Data::Model';
use Data::Model::Mixin modules => ['Queue::Q4M'];
use Data::Model::Schema;
base_driver $driver;
install_model smtp => schema {
column id
=> char => {};
column data
=> int => {};
};
install_model pop => schema {
column id
=> char => {};
column data
=> int => {};
};
}
my $model = MyQueue->new;
# add queue
$model->set(
smtp => {
id => 'foo',
data => 1,
}
);
# same queue_wait('smtp', 'pop', 10);
my $retval = $model->queue_running(
smtp => sub {
my $row = shift;
is($row->id, 'foo');
is($row->data, 1);
},
pop => sub {
my $row = shift;
},
timeout => 10, # optional
);
# same queue_wait('smtp:data>10');
my $retval = $model->queue_running(
'smtp:data>10' => sub {
my $row = shift;
is($row->id, 'foo');
is($row->data, 1);
},
);
ok($retval);
# explicit abort
my $retval = $model->queue_running(
'smtp:data>10' => sub {
my $row = shift;
is($row->id, 'foo');
is($row->data, 1);
$model->queue_abort; # queue is aborted
},
);
ok(!$retval);
Since Q4M works on MySQL, it has inherited Data::Model::Driver::DBI inevitably.
Q4M <http://q4m.31tools.com/>, Data::Model::Mixin::Queue::Q4M,
Data::Model::Mixin::DBI, Data::Model
Kazuhiro Osawa <yappo <at> shibuya <doet> pl>
This library is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.
Hey! The above document had some coding errors, which are explained
below:
- Around line 239:
- Non-ASCII character seen before =encoding in '<doet>'. Assuming
UTF-8