| 1 | package Beam::Minion::Command::run; | ||
| 2 | 2 | our $VERSION = '0.016'; | |
| 3 | # ABSTRACT: Command to enqueue a job on Beam::Minion job queue | ||
| 4 | |||
| 5 | #pod =head1 SYNOPSIS | ||
| 6 | #pod | ||
| 7 | #pod beam minion run [-d <delay>] [-a <attempts>] [-p <priority] | ||
| 8 | #pod <container> <service> [<args>...] | ||
| 9 | #pod | ||
| 10 | #pod =head1 DESCRIPTION | ||
| 11 | #pod | ||
| 12 | #pod This command adds a job to the L<Minion> queue to execute the given | ||
| 13 | #pod C<service> from the given C<container>. | ||
| 14 | #pod | ||
| 15 | #pod In order for the job to run, you must run a Minion worker using the | ||
| 16 | #pod L<beam minion worker command|Beam::Minion::Command::worker>. | ||
| 17 | #pod | ||
| 18 | #pod =head1 ARGUMENTS | ||
| 19 | #pod | ||
| 20 | #pod =head2 container | ||
| 21 | #pod | ||
| 22 | #pod The container that contains the task to run. This can be an absolute | ||
| 23 | #pod path to a container file, a relative path from the current directory, or | ||
| 24 | #pod a relative path from one of the directories in the C<BEAM_PATH> environment | ||
| 25 | #pod variable (separated by C<:>). | ||
| 26 | #pod | ||
| 27 | #pod =head2 service | ||
| 28 | #pod | ||
| 29 | #pod The service that defines the task to run. Must be an object that consumes | ||
| 30 | #pod the L<Beam::Runner> role. | ||
| 31 | #pod | ||
| 32 | #pod =head1 OPTIONS | ||
| 33 | #pod | ||
| 34 | #pod =head2 delay | ||
| 35 | #pod | ||
| 36 | #pod The amount of time, in seconds, to delay the start of the job (from now). | ||
| 37 | #pod Defaults to C<0>. | ||
| 38 | #pod | ||
| 39 | #pod =head2 attempts | ||
| 40 | #pod | ||
| 41 | #pod The number of times to automatically retry the job if it fails. | ||
| 42 | #pod Subsequent attempts will be delayed by an increasing amount of time | ||
| 43 | #pod (calculated by C<(retries ** 4) + 15>). | ||
| 44 | #pod | ||
| 45 | #pod =head2 priority | ||
| 46 | #pod | ||
| 47 | #pod The job's priority. Higher priority jobs will be run first. Defaults to C<0>. | ||
| 48 | #pod | ||
| 49 | #pod =head1 ENVIRONMENT | ||
| 50 | #pod | ||
| 51 | #pod =head2 BEAM_MINION | ||
| 52 | #pod | ||
| 53 | #pod This variable defines the shared database to coordinate the Minion workers. This | ||
| 54 | #pod database is used to queue the job. This must be the same for all workers | ||
| 55 | #pod and every job running. | ||
| 56 | #pod | ||
| 57 | #pod See L<Beam::Minion/Getting Started> for how to set this variable. | ||
| 58 | #pod | ||
| 59 | #pod =head2 BEAM_PATH | ||
| 60 | #pod | ||
| 61 | #pod This variable is a colon-separated list of directories to search for | ||
| 62 | #pod containers. | ||
| 63 | #pod | ||
| 64 | #pod =head1 SEE ALSO | ||
| 65 | #pod | ||
| 66 | #pod L<Beam::Minion>, L<Minion> | ||
| 67 | #pod | ||
| 68 | #pod =cut | ||
| 69 | |||
| 70 | 2 | ▶ | use Mojo::Base -base; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 71 | 2 | ▶ | use Beam::Minion; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 72 | 2 | ▶ | use Getopt::Long qw( GetOptionsFromArray ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 73 | |||
| 74 | sub run { | ||
| 75 | 3 | ▶ | my ( $self, $container, $service_name, @args ) = @_; |
|
Subroutine
run: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 76 | 3 | GetOptionsFromArray( \@args, \my %opt, | |
| 77 | 'delay|d=i', | ||
| 78 | 'attempts|a=i', | ||
| 79 | 'priority|p=i', | ||
| 80 | ); | ||
| 81 | 3 | Beam::Minion->enqueue( $container, $service_name, \@args, \%opt ); | |
| 82 | } | ||
| 83 | |||
| 84 | 2 | 1; | |
| 85 | |||
| 86 | __END__ | ||