Beanstalk-Client
view release on metacpan or search on metacpan
lib/Beanstalk/Client.pm view on Meta::CPAN
L<Beanstalk::Client> provides a Perl API of protocol version 1.0 to the beanstalkd server,
a fast, general-purpose, in-memory workqueue service by Keith Rarick.
=head1 METHODS
=head2 Constructor
=over
=item B<new ($options)>
The constructor accepts a single argument, which is a reference to a hash containing options.
The options can be any of the accessor methods listed below.
=back
=head2 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<socket>
Get the socket connection to the server.
=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)
=item B<encoder ([$encoder])>
Set/get serialization encoder. C<$encoder> is a reference to a subroutine
that will be called when arguments to C<put> need to be encoded to send
to the beanstalkd server. The subroutine should accept a list of arguments and
return a string representation to pass to the server. (Default: YAML::Syck::Dump)
=item B<decoder ([$decoder])>
Set/get the serialization decoder. C<$decoder> is a reference to a
subroutine that will be called when data from the beanstalkd server needs to be
decoded. The subroutine will be passed the data fetched from the beanstalkd
server and should return a list of values the application can use.
(Default: YAML::Syck::Load)
=item B<error>
Fetch the last error that happened.
=item B<connect_timeout ([$timeout])>
Get/set timeout, in seconds, to use for the connect to the server.
=item B<default_tube ([$tube])>
Set/get the name of a default tube to put jobs into and fetch from.
By default a connection to a beanstalkd server will put into the C<default>
queue and also watch the C<default> queue. If C<default_tube> is set when
C<connect> is called the connection will be initialized so that C<put> will put
into the given tube and C<reserve> will fetch jobs from the given tube.
(Default: none)
=item B<debug ([$debug])>
Set/get debug value. If set to a true value then all communication with the server will be
output with C<warn>
=back
=head2 Producer Methods
These methods are used by clients that are placing work into the queue
=over
=item B<put ($options [, @args])>
Insert job into the currently used tube. Options may be
=over
=item priority
priority to use to queue the job.
Jobs with smaller priority values will be
scheduled before jobs with larger priorities. The most urgent priority is 0
Defaults to C<$self->priority>
=item delay
An integer number of seconds to wait before putting the job in
the ready queue. The job will be in the "delayed" state during this time
Defaults to C<$self->delay>
=item ttr
"time to run" - An integer number of seconds to allow a worker
to run this job. This time is counted from the moment a worker reserves
this job. If the worker does not delete, release, or bury the job within
( run in 0.665 second using v1.01-cache-2.11-cpan-39bf76dae61 )