File Coverage

blib/lib/Beam/Minion/Command/run.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 20 21 95.2


line stmt bran cond sub pod time code
1             package Beam::Minion::Command::run;
2             our $VERSION = '0.014';
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 ] [-a ] [-p
8             #pod [...]
9             #pod
10             #pod =head1 DESCRIPTION
11             #pod
12             #pod This command adds a job to the L queue to execute the given
13             #pod C from the given C.
14             #pod
15             #pod In order for the job to run, you must run a Minion worker using the
16             #pod L.
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 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 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 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, L
67             #pod
68             #pod =cut
69              
70 1     1   51685 use strict;
  1         6  
  1         20  
71 1     1   4 use warnings;
  1         2  
  1         16  
72 1     1   358 use Beam::Minion;
  1         3  
  1         32  
73 1     1   8 use Getopt::Long qw( GetOptionsFromArray );
  1         2  
  1         8  
74              
75             sub run {
76 3     3 0 99888 my ( $class, $container, $service_name, @args ) = @_;
77 3         30 GetOptionsFromArray( \@args, \my %opt,
78             'delay|d=i',
79             'attempts|a=i',
80             'priority|p=i',
81             );
82 3         1360 Beam::Minion->enqueue( $container, $service_name, \@args, \%opt );
83             }
84              
85             1;
86              
87             __END__