Daisuke Maki > Swarmage-0.01005 > Swarmage::Drone

Download:
Swarmage-0.01005.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Source  

NAME ^

Swarmage::Drone - The Drone

SYNOPSIS ^

  use Swarmage;
  Swarmage::Drone->new(
    queues => [
      {
        module => 'DBI::Generic',
        config => {
          connect_info => [
            'dbi:Pg:dbname=swarmage',
            $username,
            $password,
            ...
          ],
          taks_types   => [ qw(foo bar) ],
        },
      }
    ],
    workers => {
        foo => {
            module => '+MyWorker',
            config => {
                ....
            }
        },
        # multiple workers
        bar => [
            {
                module => '+MyWorker2',
                config => {
                    ...
                }
            },
            {
                module => '+MyWorker2',
                config => {
                    ...
                }
            },
        ]
    }
  );
  POE::Kernel->run();

DESCRIPTION ^

The Drone is responsible for retrieving jobs from the system queue, then launching, and keeping track of workers. It's assumed that a Drone may contain multiple types of Workers, and that these Workers coordinate with each other, thus forming a small cluster of processes that implement a particular logic set.

The Drone uses two sets of queues. One is the Global Queue, which is the queue that is shared amongst Drones. The other is the Local Queue, which is shared between one Drone and one or more Workers belonging to that Drone.

The Global Queue may be implemented in terms of a database, a message queue, or whatever that handles its own non-blocking logic to check for incoming tasks. The Local Queue is implemeted with a simple SQLite database.

When an incoming task is notified by the Queue, the Drone checks the job's type, and dispatches to the appropriate Worker.

METHODS ^

new

postback

register_worker

mark_worker_done

setup_log

pump_queue

monitor

syntax highlighting: