GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Queue::Beanstalk(3) User Contributed Perl Documentation Queue::Beanstalk(3)

Queue::Beanstalk - Client library for the beanstalkd server

Producer example:

  use Queue::Beanstalk;
  
  $jobs = Queue::Beanstalk->new(
                                 'servers' =>  [ '127.0.0.1:11300' ],
                                 'connect_timeout' => 2,
  );
  
  # Adds a job with priority 4294967295 and 0 delay  
  $jobs->put('do:something');
  
  # Adds a job with 0 (highest) priority and 1 second delay
  $jobs->put(('do:somethingelse', 0, 1);

Worker example:

  use Queue::Beanstalk;
  
  $jobs = Queue::Beanstalk->new(
                                 'servers' =>  [ '127.0.0.1:11300' ],
                                 'connect_timeout' => 2,
  );
  
  while (1) {
    my $data;
    
    if ($data = $jobs->reserve()) {
  
      if (do_something($data)) {
        $jobs->delete();  # done with the job
      } else {
        $jobs->release(); # i failed, let someone else take it
      }
      $jobs->next_server(); # optional, if you have several servers
  
    }
  
    sleep(1); # prevent cpu intensive loop (just in case)
  }

WARNING! This module is marked as being in the alpha stage, and is therefore subject to change in near future. This version of Queue::Beanstalk currently supports the 0.6 protocol version of Beanstalkd.

Client library for Beanstalk. Read more about the Beanstalkd daemon at

  http://xph.us/software/beanstalkd/

Has the following hashref options:
"servers"
An arrayref of servers that can be connected to. Must be in the host:port format. By default the module wil randomly select a server to connect to. You can change this behaviour with the random_servers option.
"random_servers"
If given a false value, the module will follow the order of the servers array and select the next server in the list on subsequent calls to next_server(); When using this module as a 'producer', it is best to leave the default value of true, so the clients will randomly connect to one of your beantalkd servers.
"auto_next_server"
Will automatically go to the next or a random server after a successful "put" or "delete". Default value is false.
"report_errors"
When given a false value, the module will not give any errormessages out loud. And will only exit the functions with an undefined value, the corresponding error-messages however will be found in the 'errstr' variable of the object.
"connect_timeout"
Amount of seconds to wait for a connection to go through. Default is 0.25 second.
"select_timeout"
Amount of seconds to wait for a socket to have data available. Default is 1 second.
"reserve_timeout"
Amount of seconds to wait for an available job to reserve. Default is 10 seconds.

$jobs->put($job_data[, $priority, $delay])

Insert a job into the queue. Priority is an integer between 0 (highest) and 4294967295 (lowest). Default priority is 4294967295. Default delay is 0.

Returns an undefined value on errors, 'inserted' or 'burried'.

$jobs->stats();

Returns YAML stats output from beanstalkd. TODO: Parse yaml and return hashref.

$jobs->reserve();

Returns undef on failure/timeout, or full job-data if successful. You have 120 seconds to fullfil the job, before beanstalkd gives up on you.

$jobs->release([$priority, $delay]);

Release the current reserved job. The default is to use the same priority as the job had, and 0 second delay.

$jobs->delete();

Delete the current reserved job. Removes the job from the queue as the job is finished.

Haakon Nessjoen, Loopback Systems AS, <lunatic@cpan.org>

Copyright (c) 2007 by Loopback Systems AS

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.

Hey! The above document had some coding errors, which are explained below:
Around line 620:
Non-ASCII character seen before =encoding in 'Haakon'. Assuming CP1252
2022-04-08 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.