AnyEvent-Beanstalk
view release on metacpan or search on metacpan
lib/AnyEvent/Beanstalk.pm view on Meta::CPAN
return unless $self->{_sock};
my $watching = $self->{__watching} or return;
return keys %$watching;
}
sub using {
my $self = shift;
return $self->{__using};
}
sub sync {
my $self = shift;
while ($self->{_condvar} and my ($cv) = values %{$self->{_condvar}}) {
$cv->recv;
}
}
1;
__END__
=encoding utf-8
=head1 NAME
AnyEvent::Beanstalk - Async client to talk to beanstalkd server
=head1 VERSION
version 1.170590
=head1 SYNOPSIS
use AnyEvent::Beanstalk;
my $client = AnyEvent::Beanstalk->new(
server => "localhost",
);
# Send a job with explicit data
my $job = $client->put(
{ data => "data",
priority => 100,
ttr => 120,
delay => 5,
}
)->recv;
# Send job, data created by encoding @args. By default with YAML
my $job2 = $client->put(
{ priority => 100,
ttr => 120,
delay => 5,
encode => \@args,
}
)->recv;
# Send job, data created by encoding @args with JSON
use JSON::XS;
$client->encoder(\&JSON::XS::encode_json);
my $job2 = $client->put(
{ priority => 100,
ttr => 120,
delay => 5,
encode => \@args,
},
)->recv;
# fetch a job, with a callback
$client->reserve( sub { my $job = shift; process_job($job) });
=head1 DESCRIPTION
L<AnyEvent::Beanstalk> provides a Perl API of protocol version 1.3 to the beanstalkd server,
a fast, general-purpose, in-memory workqueue service by Keith Rarick.
See the L<beanstalkd 1.3 protocol spec|http://github.com/kr/beanstalkd/blob/v1.3/doc/protocol.txt?raw=true>
for greater detail
=head1 METHODS
=head2 Constructor
=over
=item B<new (%options)>
Any of the attributes with accessor methods described below may be passed to the constructor as key-value pairs
=back
=head2 Attribute Accessor Methods
=over
=item B<server ([$hostname])>
Get/set the hostname, and port, to connect to. The port, which defaults to 11300, can be
specified by appending it to the hostname with a C<:> (eg C<"localhost:1234">).
(Default: C<localhost:11300>)
=item B<delay ([$delay])>
Set/get a default value, in seconds, for job delay. A job with a delay will be
placed into a delayed state and will not be placed into the ready queue until
the time period has passed. This value will be used by C<put> and C<release> as
a default. (Default: 0)
=item B<ttr ([$ttr])>
Set/get a default value, in seconds, for job ttr (time to run). This value will
be used by C<put> as a default. (Default: 120)
=item B<priority ([$priority])>
Set/get a default value for job priority. The highest priority job is the job
where the priority value is the lowest (ie jobs with a lower priority value are
run first). This value will be used by C<put>, C<release> and C<bury> as a
default. (Default: 10000)
( run in 0.948 second using v1.01-cache-2.11-cpan-6aa56a78535 )