DR-TarantoolQueue

 view release on metacpan or  search on metacpan

benchmark/1.5/channel.pl  view on Meta::CPAN

use Data::Dumper;

my $t = DR::Tarantool::StartTest->run(
    cfg         => catfile(cwd, 'queue-lts/tarantool.cfg'),
    script_dir  => catfile(cwd, 'benchmark/1.5')
);

sub tnt {
    our $tnt;
    unless(defined $tnt) {
        $tnt = coro_tarantool
            host => 'localhost',
            port => $t->primary_port,
            spaces => {}
        ;
    }
    return $tnt;
};

tnt->ping;

benchmark/1.5/ping.pl  view on Meta::CPAN

use Data::Dumper;

my $t = DR::Tarantool::StartTest->run(
    cfg         => catfile(cwd, 'queue-lts/tarantool.cfg'),
    script_dir  => catfile(cwd, 'benchmark')
);

sub tnt {
    our $tnt;
    unless(defined $tnt) {
        $tnt = coro_tarantool
            host => 'localhost',
            port => $t->primary_port,
            spaces => {}
        ;
    }
    return $tnt;
};

$| = 1;

benchmark/1.5/queue.pl  view on Meta::CPAN

use Coro::AnyEvent;

my $t = DR::Tarantool::StartTest->run(
    cfg         => catfile(cwd, 'queue-lts/tarantool.cfg'),
    script_dir  => catfile(cwd, 'queue-lts/queue')
);

sub tnt {
    our $tnt;
    unless(defined $tnt) {
        $tnt = coro_tarantool
            host => 'localhost',
            port => $t->primary_port,
            spaces => {}
        ;
    }
    return $tnt;
};

tnt->ping;

debian/control  view on Meta::CPAN

Source: dr-tarantool-queue
Section: database
Priority: optional
Maintainer: Dmitry E. Oboukhov <unera@debian.org>
Uploaders: Roman V. Nikolaev <rshadow@rambler.ru>
Build-Depends: debhelper (>= 8)
Build-Depends-Indep: libcoro-perl,
 libdr-tarantool-perl,
 liblist-moreutils-perl,
 libjson-xs-perl,
 libmouse-perl,
 libcoro-perl,
 perl,
 tarantool-lts | tarantool (>= 1.7)
Standards-Version: 3.9.6

Package: libdr-tarantoolqueue-perl
Section: perl
Architecture: all
Suggests: dr-tarantool-queue
Depends: ${misc:Depends}, ${perl:Depends},
 libcoro-perl,
 libdr-tarantool-perl | libdr-tnt-perl,
 libjson-xs-perl,
 libmouse-perl,
 liblist-moreutils-perl,
 libcoro-perl
Homepage: http://search.cpan.org/dist/DR-TarantoolQueue/
Description: client for tarantool's queue
 The module contains sync and async (coro) driver for tarantool queue.

Package: dr-tarantool-queue
Architecture: all
Section: database
Suggests: libdr-tarantoolqueue-perl
Depends: ${misc:Depends}, ${perl:Depends},
 tarantool-lts | tarantool (>= 1.4.8+20130110-1)
Homepage: https://github.com/mailru/tarantool-queue/
Description: queue components for tarantool
 The package contains init.lua and tarantool.cfg to build queue daemon

lib/DR/TarantoolQueue.pm  view on Meta::CPAN


    # put empty task into queue with name 'request_queue'
    my $task = $queue->put;

    my $task = $queue->put(data => [ 1, 2, 3 ]);

    printf "task.id = %s\n", $task->id;

=head2 DESCRIPTION

The module contains sync and async (coro) driver for tarantool queue.

=head1 ATTRIBUTES

=head2 host (ro) & port (ro)

Tarantool's parameters.

=head2 connect_opts (ro)

Additional options for L<DR::Tarantool>. HashRef.

lib/DR/TarantoolQueue.pm  view on Meta::CPAN

    queue:init()
    
    log.info('Fake Queue started')

=head2 msgpack (ro)

If true, the driver will use L<DR::Tnt> driver (C<1.6>). Also it will use
L<tarantool-megaqueue|https://github.com/dr-co/tarantool-megaqueue> lua
module with namespace C<queue>.

=head2 coro (ro)

If B<true> (default) the driver will use L<Coro> tarantool's driver,
otherwise the driver will use sync driver.

=head2 ttl (rw)

Default B<ttl> for tasks.

=head2 ttr (rw)

lib/DR/TarantoolQueue.pm  view on Meta::CPAN


=cut

with 'DR::TarantoolQueue::JSE';

has host            => is => 'ro', isa => 'Maybe[Str]';
has port            => is => 'ro', isa => 'Maybe[Str]';
has user            => is => 'ro', isa => 'Maybe[Str]';
has password        => is => 'ro', isa => 'Maybe[Str]';

has coro            => is => 'ro', isa => 'Bool',  default  => 1;

has ttl             => is => 'rw', isa => 'Maybe[Num]';
has ttr             => is => 'rw', isa => 'Maybe[Num]';
has pri             => is => 'rw', isa => 'Maybe[Num]';
has delay           => is => 'rw', isa => 'Maybe[Num]';
has space           => is => 'rw', isa => 'Maybe[Str]';
has tube            => is => 'rw', isa => 'Maybe[Str]';
has connect_opts    => is => 'ro', isa => 'HashRef', default => sub {{}};

has defaults        => is => 'ro', isa => 'HashRef', default => sub {{}};

lib/DR/TarantoolQueue/Tnt.pm  view on Meta::CPAN

        return $self->_build_msgpack_tnt if $self->msgpack;
        return $self->_build_lts_tnt;
    }
;

sub _build_msgpack_tnt {
    my ($self) = @_;
    require DR::Tnt;

    my $driver = 'sync';
    $driver = 'coro' if $self->coro;


    my ($host, $port, $user, $password) =
        ($self->host, $self->port, $self->user, $self->password);

    # in test
    if ($self->_fake_msgpack_tnt) {
        $host = '127.0.0.1';
        $port = $self->_fake_msgpack_tnt->port;
        $user = 'test';

lib/DR/TarantoolQueue/Tnt.pm  view on Meta::CPAN

sub _build_lts_tnt {
    my ($self) = @_;
    require DR::Tarantool;

    my ($host, $port) = ($self->host, $self->port);
    if ($self->_fake_lts_tnt) {
        $host = '127.0.0.1';
        $port = $self->_fake_lts_tnt->primary_port;
    }

    unless ($self->coro) {
        if (DR::Tarantool->can('rsync_tarantool')) {
            return DR::Tarantool::rsync_tarantool(
                port => $port,
                host => $host,
                spaces => {},
                %{ $self->connect_opts }
            );
        } else {
            return DR::Tarantool::tarantool(
                port => $port,
                host => $host,
                spaces => {},
                %{ $self->connect_opts }
            );
        }
    }

    return DR::Tarantool::coro_tarantool(
        port => $port,
        host => $host,
        spaces => {},
        %{ $self->connect_opts }
    );
}

1;

t/010-tarantool-1.5/000-queue.t  view on Meta::CPAN

$SIG{INT} = sub {
    note $t->log if $ENV{DEBUG};
    $t->kill('KILL');
    exit 2;
};

our $tnt;
sub tnt {
    unless($tnt) {
        $tnt = eval {
            coro_tarantool
                host => 'localhost',
                port => $t->primary_port,
                spaces => {
                    0   => {
                        name            => 'queue',
                        default_type    => 'STR',
                        fields          => [
                            qw(uuid tube status),
                            {
                                type => 'NUM64',

t/010-tarantool-1.5/010-dr-tqueue.t  view on Meta::CPAN

    space           => 0,
    tube            => 'test_queue',
    fake_in_test    => 0,
);

my $qs = DR::TarantoolQueue->new(
    host            => '127.0.0.1',
    port            => $t->primary_port,
    space           => 0,
    tube            => 'test_queue',
    coro            => 0,
    fake_in_test    => 0,
);

isa_ok $q => 'DR::TarantoolQueue';

my (@f, @fh);
push @f => async {
    ok $q->tnt->ping, 'tnt ping';
    push @fh => fileno($q->tnt->_llc->{fh})
} for 1 .. 5;

t/010-tarantool-1.5/010-dr-tqueue.t  view on Meta::CPAN

        'Unique tasks putting has equal ids';

}
{
    use Scalar::Util 'refaddr';
    $q = DR::TarantoolQueue->new(
        host    => '127.0.0.1',
        port    => $t->primary_port,
        space   => 0,
        tube    => 'test_queue',
        coro    => 1
    );
    ok $q, 'queue instance is created';
    is $q->{tnt}, undef, 'connection is not created yet';

    my (@clist, @f);
    for (1 .. 100) {
        push @f => async { $q->put(data => $_) };
        push @clist => $q->{tnt};
    }
    $_->join for @f;

t/020-tnt-msgpack/010-queue.t  view on Meta::CPAN


diag $t->log unless ok $t->is_started, 'Queue was started';


my $q = DR::TarantoolQueue->new(
    host        => '127.0.0.1',
    port        => $t->port,
    user        => 'test',
    password    => 'test',
    msgpack     => 1,
    coro        => 0,

    tube        => 'test_tube',

    ttl         => 60,

    defaults    => {
        test_tube   => {
            ttl         => 80
        }
    },

t/020-tnt-msgpack/020-operations.t  view on Meta::CPAN

}


my $t = start_tarantool
    -port   => free_port,
    -lua    => 't/020-tnt-msgpack/lua/queue.lua',
;

diag $t->log unless ok $t->is_started, 'Queue was started';

for my $coro (0, 1) {
    my $q = DR::TarantoolQueue->new(
        host        => '127.0.0.1',
        port        => $t->port,
        user        => 'test',
        password    => 'test',
        msgpack     => 1,
        coro        => $coro,

        tube        => 'test_tube',

        ttl         => 60,

        defaults    => {
            test_tube   => {
                ttl         => 80
            }
        },

t/020-tnt-msgpack/025-delay.t  view on Meta::CPAN

;

diag $t->log unless ok $t->is_started, 'Queue was started';

my $q = DR::TarantoolQueue->new(
    host        => '127.0.0.1',
    port        => $t->port,
    user        => 'test',
    password    => 'test',
    msgpack     => 1,
    coro        => 0,

    tube        => 'test_tube',

    ttl         => 60,

    defaults    => {
        test_tube   => {
            ttl         => 80
        }
    },

t/020-tnt-msgpack/030-stress.t  view on Meta::CPAN

my $ch = Coro::Channel->new;
my $cht = Coro::Channel->new;

for my $i (0 .. 99) {
    my $q = DR::TarantoolQueue->new(
        host        => '127.0.0.1',
        port        => $t->port,
        user        => 'test',
        password    => 'test',
        msgpack     => 1,
        coro        => 1,

        tube        => 'test_tube',

        ttl         => 60,

        defaults    => {
            test_tube   => {
                ttl         => 80
            }
        },

t/020-tnt-msgpack/500-worker.t  view on Meta::CPAN

diag $t->log unless ok $t->is_started, 'Queue was started';


my $q = DR::TarantoolQueue->new(
    host        => '127.0.0.1',
    port        => $t->port,
    user        => 'test',
    password    => 'test',
    msgpack     => 1,
    tube        => 'test_queue',
    coro        => 1,
    fake_in_test    => 0,
);

isa_ok $q => 'DR::TarantoolQueue';



my $wrk = DR::TarantoolQueue::Worker->new(
    queue   => $q,
    timeout => .5,



( run in 0.416 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )