Beam::Minion - A distributed task runner for Beam::Wire containers
version 0.014
# Command-line interface export BEAM_MINION=sqlite://test.db beam minion worker beam minion run <container> <service> [<args>...] beam minion help # Perl interface local $ENV{BEAM_MINION} = 'sqlite://test.db'; Beam::Minion->enqueue( $container, $service, \@args, \%opt );
Beam::Minion is a distributed task runner. One or more workers are created to run tasks, and then each task is sent to a worker to be run. Tasks are configured as Beam::Runnable objects by Beam::Wire container files.
Beam::Minion->enqueue( $container_name, $task_name, \@args, \%opt );
Enqueue the task named $task_name from the container named $container_name. The BEAM_MINION environment variable must be set.
$task_name
$container_name
BEAM_MINION
\%opt is a hash reference with the following keys:
\%opt
Number of times to retry this job if it fails. Defaults to 1.
1
Time (in seconds) to delay this job (from now). Defaults to 0.
0
The job priority. Higher priority jobs get performed first. Defaults to 0.
(These are the same options allowed in the Minion "enqueue" method)
To start running your Beam::Runner jobs, you must first start a Minion worker with the beam minion worker.command. Minion requires a database to coordinate workers, and communicates with this database using a Minion::Backend.
The supported Minion backends are:
Minion::Backend::SQLite - sqlite:<db_path>
sqlite:<db_path>
Minion::Backend::Pg - postgresql://<user>:<pass>@<host>/<database>
postgresql://<user>:<pass>@<host>/<database>
Minion::Backend::mysql - mysql://<user>:<pass>@<host>/<database>
mysql://<user>:<pass>@<host>/<database>
Minion::Backend::MongoDB - mongodb://<host>:<port>
mongodb://<host>:<port>
Once you've picked a database backend, configure the BEAM_MINION environment variable with the URL. Minion will automatically deploy the database tables it needs, so be sure to allow the right permissions (if the database has such things).
In order to communicate with Minion workers on other machines, it will be necessary to use a database accessible from the network (so, not SQLite).
Once the BEAM_MINION environment variable is set, you can start a worker with beam minion worker. Each worker can run jobs from all the containers it can find from the BEAM_PATH environment variable. Each worker will run up to 4 jobs concurrently.
beam minion worker
BEAM_PATH
Jobs are spawned with beam minion run <container> <service>. The service must be an object that consumes the Beam::Runnable role. container should be a path to a container file and can be an absolute path, a path relative to the current directory, or a path relative to one of the paths in the BEAM_PATH environment variable (separated by :).
beam minion run <container> <service>
service
container
:
You can queue up jobs before you have workers running. As soon as a worker is available, it will start running jobs from the queue.
Beam::Wire, Beam::Runner, Minion
Doug Bell <preaction@cpan.org>
Mohammad S Anwar <mohammad.anwar@yahoo.com>
This software is copyright (c) 2018 by Doug Bell.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Beam::Minion, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Beam::Minion
CPAN shell
perl -MCPAN -e shell install Beam::Minion
For more information on module installation, please visit the detailed CPAN module installation guide.