DR-TarantoolQueue
view release on metacpan or search on metacpan
lib/DR/TarantoolQueue.pm view on Meta::CPAN
Default B<ttl> for tasks.
=head2 ttr (rw)
Default B<ttr> for tasks.
=head2 pri (rw)
Default B<pri> for tasks.
=head2 delay (rw)
Default B<delay> for tasks.
=head2 space (rw)
Default B<space> for tasks.
=head2 tube (rw)
Default B<tube> for tasks.
=head2 defaults
Defaults for queues. B<HashRef>. Key is tube name. Value is a hash with
the following fields:
=over
=item ttl
=item ttr
=item delay
=item pri
=back
Methods L</put> (L</urgent>) use these parameters if they
are absent (otherwise it uses the same global attributes).
=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 {{}};
has msgpack => is => 'ro', isa => 'Bool', default => 0;
# еÑли $0 =~ /\.t$/ Ñо бÑÐ´ÐµÑ Ð·Ð°Ð¿ÑÑкаÑÑ ÑейковÑй ÑаÑанÑÑл
has fake_in_test => is => 'ro', isa => 'Bool', default => 1;
sub _check_opts($@) {
my $h = shift;
my %can = map { ($_ => 1) } @_;
for (keys %$h) {
next if $can{$_};
croak 'unknown option: ' . $_;
}
}
sub _producer_messagepack {
my ($self, $method, $o) = @_;
state $alias = {
urgent => 'put',
};
$method = $alias->{$method} if exists $alias->{$method};
_check_opts $o, qw(space tube delay ttl ttr pri data domain);
my $tube = $o->{tube};
$tube = $self->tube unless defined $tube;
croak 'tube was not defined' unless defined $tube;
for ('ttl', 'delay', 'ttr', 'pri') {
my $n = $_;
my $res;
if (exists $o->{$n}) {
$res = $o->{$n};
} else {
if (exists $self->defaults->{ $tube }) {
if (exists $self->defaults->{ $tube }{ $n }) {
$res = $self->defaults->{ $tube }{ $n };
} else {
$res = $self->$n;
}
} else {
$res = $self->$n;
}
}
$res ||= 0;
if ($res == 0) {
delete $o->{ $n };
} else {
$o->{ $n } = $res;
}
}
my $task = $self->tnt->call_lua(
( run in 1.712 second using v1.01-cache-2.11-cpan-39bf76dae61 )