NAME

Data::Model::Driver::Queue::Q4M - Q4M manager for Data::Model

SYNOPSIS

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);

DESCRIPTION

Since Q4M works on MySQL, it has inherited Data::Model::Driver::DBI inevitably.

SEE ALSO

Q4M http://q4m.31tools.com/, Data::Model::Mixin::Queue::Q4M, Data::Model::Mixin::DBI, Data::Model

AUTHOR

Kazuhiro Osawa <yappo <at> shibuya <döt> pl>

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 235:

Non-ASCII character seen before =encoding in '<döt>'. Assuming UTF-8