| 1 | package Punk::Queue::Command; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 70 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 70 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 70 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 70 | ▶ | use Getopt::Long (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 70 | ▶ | use Punk::Queue (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 70 | our $VERSION = '0.11'; | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | # The subcommands behind `punk-queue`. Each returns an exit code - 0 fine, | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # 1 the thing you asked about is wrong (job not found, schema behind), 2 | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # the command was used wrongly - and prints its own report, so bin/punk-queue | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # stays a dispatcher. This is the Punk::Command shape. | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # The governing rule from the plan: anything the admin UI can do, the CLI | ||||||||||||||||||||||||||||||||||||||||||
| 17 | # can do, and every subcommand works from --dsn alone - inspection must | ||||||||||||||||||||||||||||||||||||||||||
| 18 | # never require loading the app. | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 70 | our @COMMANDS = qw(worker enqueue job jobs workers stats repair locks | |||||||||||||||||||||||||||||||||||||||||
| 21 | lock unlock broadcast crons cron migrate reset version | ||||||||||||||||||||||||||||||||||||||||||
| 22 | help); | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub commands { @COMMANDS } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
commands: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 77 | ▶ | sub main { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
main: called CC=7 SCAR=19.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 77 | my (@argv) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 77 | ▶ | if (!@argv || $argv[0] eq '-h' || $argv[0] eq '--help') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
not @argv or $argv[0] eq "-h" or $argv[0] eq "--help"
not @argv or $argv[0] eq "-h"
MC/DC33%1/3
not @argv or $argv[0] eq "-h" or $argv[0] eq "--help"
not @argv
$argv[0] eq "-h"
$argv[0] eq "--help"
Truth table50%2/4
not(A) or B or C
A= not @argvB= $argv[0] eq "-h"C= $argv[0] eq "--help"
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | usage(\*STDOUT); | |||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 76 | ▶ | if ($argv[0] eq '-v' || $argv[0] eq '--version') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$argv[0] eq "-v" or $argv[0] eq "--version"
MC/DC50%1/2
$argv[0] eq "-v" or $argv[0] eq "--version"
$argv[0] eq "-v"
$argv[0] eq "--version"
Truth table66%2/3
A or B
A= $argv[0] eq "-v"B= $argv[0] eq "--version"
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | print "punk-queue $VERSION (Punk::Queue $Punk::Queue::VERSION)\n"; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 75 | my $cmd = shift @argv; | |||||||||||||||||||||||||||||||||||||||||
| 39 | my %commands = ( | ||||||||||||||||||||||||||||||||||||||||||
| 40 | worker => \&worker, | ||||||||||||||||||||||||||||||||||||||||||
| 41 | enqueue => \&enqueue, | ||||||||||||||||||||||||||||||||||||||||||
| 42 | job => \&job, | ||||||||||||||||||||||||||||||||||||||||||
| 43 | jobs => \&jobs, | ||||||||||||||||||||||||||||||||||||||||||
| 44 | workers => \&workers, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | stats => \&stats, | ||||||||||||||||||||||||||||||||||||||||||
| 46 | repair => \&repair, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | locks => \&locks, | ||||||||||||||||||||||||||||||||||||||||||
| 48 | lock => \&lock, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | unlock => \&unlock, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | broadcast => \&broadcast, | ||||||||||||||||||||||||||||||||||||||||||
| 51 | crons => \&crons, | ||||||||||||||||||||||||||||||||||||||||||
| 52 | cron => \&cron, | ||||||||||||||||||||||||||||||||||||||||||
| 53 | migrate => \&migrate, | ||||||||||||||||||||||||||||||||||||||||||
| 54 | reset => \&reset, | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | version => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | print "punk-queue $VERSION (Punk::Queue $Punk::Queue::VERSION)\n"; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | 0; | |||||||||||||||||||||||||||||||||||||||||
| 58 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | ▶ | help => sub { usage(\*STDOUT); 0 }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 75 | ); | |||||||||||||||||||||||||||||||||||||||||
| 61 | 75 | ▶ | my $run = $commands{$cmd} or do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | print STDERR "punk-queue: unknown command '$cmd'\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 2 | usage(\*STDERR); | |||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | return 2; | |||||||||||||||||||||||||||||||||||||||||
| 65 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 73 | return $run->(@argv); | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 4 | ▶ | sub usage { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
usage: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 4 | my ($fh) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 4 | print {$fh} <<'EOU'; | |||||||||||||||||||||||||||||||||||||||||
| 72 | Usage: punk-queue COMMAND [options] | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | Every command takes --dsn DSN or --app CLASS-OR-FILE to reach the queue; | ||||||||||||||||||||||||||||||||||||||||||
| 75 | inspection never requires the app. Read commands take --json. | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | Commands: | ||||||||||||||||||||||||||||||||||||||||||
| 78 | worker run a supervised worker pool | ||||||||||||||||||||||||||||||||||||||||||
| 79 | -q, --queue NAME (repeatable, or comma separated) | ||||||||||||||||||||||||||||||||||||||||||
| 80 | -t, --task NAME restrict to these tasks (repeatable) | ||||||||||||||||||||||||||||||||||||||||||
| 81 | -j, --jobs N child processes (default 1) | ||||||||||||||||||||||||||||||||||||||||||
| 82 | --interval SECS idle claim interval (default 0.5) | ||||||||||||||||||||||||||||||||||||||||||
| 83 | --max-jobs N recycle a child after N jobs | ||||||||||||||||||||||||||||||||||||||||||
| 84 | --graceful-timeout S wait this long on shutdown (default 60) | ||||||||||||||||||||||||||||||||||||||||||
| 85 | --fail-fast exit 1 if children keep dying at boot | ||||||||||||||||||||||||||||||||||||||||||
| 86 | --no-scheduler do not run the cron scheduler in this pool | ||||||||||||||||||||||||||||||||||||||||||
| 87 | enqueue add a job: punk-queue enqueue TASK [ARGS...] | ||||||||||||||||||||||||||||||||||||||||||
| 88 | -q, --queue NAME -p, --priority N --delay SECS | ||||||||||||||||||||||||||||||||||||||||||
| 89 | --attempts N --expire SECS --timeout SECS | ||||||||||||||||||||||||||||||||||||||||||
| 90 | --parent ID (repeatable) --lax --unique KEY | ||||||||||||||||||||||||||||||||||||||||||
| 91 | --json '[...]' (whole args array) | ||||||||||||||||||||||||||||||||||||||||||
| 92 | job one job: punk-queue job ID [ID...] | ||||||||||||||||||||||||||||||||||||||||||
| 93 | --retry [--delay S --priority N --queue NAME] | ||||||||||||||||||||||||||||||||||||||||||
| 94 | --remove --fail REASON --json | ||||||||||||||||||||||||||||||||||||||||||
| 95 | --log print the job's log (lifecycle + $job->log lines) | ||||||||||||||||||||||||||||||||||||||||||
| 96 | jobs list jobs | ||||||||||||||||||||||||||||||||||||||||||
| 97 | --state S --queue Q --task T --worker W | ||||||||||||||||||||||||||||||||||||||||||
| 98 | --limit N --offset N --json | ||||||||||||||||||||||||||||||||||||||||||
| 99 | workers list workers [--role R --json] | ||||||||||||||||||||||||||||||||||||||||||
| 100 | stats queue statistics [--json] | ||||||||||||||||||||||||||||||||||||||||||
| 101 | repair fix what crashes leave [--deep: recompute dependency counters] | ||||||||||||||||||||||||||||||||||||||||||
| 102 | locks list locks [--name N --json] | ||||||||||||||||||||||||||||||||||||||||||
| 103 | lock acquire: punk-queue lock NAME [--duration S --limit N --owner ID] | ||||||||||||||||||||||||||||||||||||||||||
| 104 | unlock release: punk-queue unlock NAME [--owner ID] | ||||||||||||||||||||||||||||||||||||||||||
| 105 | broadcast send a command to workers: punk-queue broadcast CMD [ARGS] | ||||||||||||||||||||||||||||||||||||||||||
| 106 | [--worker ID (repeatable; default all)] | ||||||||||||||||||||||||||||||||||||||||||
| 107 | crons list recurring jobs [--json] | ||||||||||||||||||||||||||||||||||||||||||
| 108 | cron one cron: | ||||||||||||||||||||||||||||||||||||||||||
| 109 | run NAME enqueue its job now (schedule untouched) | ||||||||||||||||||||||||||||||||||||||||||
| 110 | enable NAME resume firing (next_run recomputed from now) | ||||||||||||||||||||||||||||||||||||||||||
| 111 | disable NAME stop firing (history and row kept) | ||||||||||||||||||||||||||||||||||||||||||
| 112 | next EXPR print the next occurrences [--tz TZ --count N] | ||||||||||||||||||||||||||||||||||||||||||
| 113 | (needs no database) | ||||||||||||||||||||||||||||||||||||||||||
| 114 | migrate apply schema migrations [--check: exit 1 if behind] | ||||||||||||||||||||||||||||||||||||||||||
| 115 | reset empty the queue (requires --yes) | ||||||||||||||||||||||||||||||||||||||||||
| 116 | version print the version | ||||||||||||||||||||||||||||||||||||||||||
| 117 | help this text | ||||||||||||||||||||||||||||||||||||||||||
| 118 | EOU | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 4 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | # ---- shared plumbing -------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | # Getopt::Long::Parser grew a getoptionsfromarray method in 2.39, so the | ||||||||||||||||||||||||||||||||||||||||||
| 125 | # object form is out: perl 5.16 and older ship 2.38. Configure returns the | ||||||||||||||||||||||||||||||||||||||||||
| 126 | # previous settings and takes them back, which is the same save/restore the | ||||||||||||||||||||||||||||||||||||||||||
| 127 | # parser object does internally, and it works everywhere. | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 72 | ▶ | sub _getopt { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_getopt: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 72 | my ($argv, @spec) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 72 | my $prev = Getopt::Long::Configure( | |||||||||||||||||||||||||||||||||||||||||
| 131 | qw(default no_ignore_case bundling pass_through)); | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 72 | my $ok = eval { Getopt::Long::GetOptionsFromArray($argv, @spec) }; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 72 | my $err = $@; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 72 | Getopt::Long::Configure($prev); | |||||||||||||||||||||||||||||||||||||||||
| 135 | 72 | ▶ | die $err if $err; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 72 | return $ok; | |||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | # The queue, from --dsn or --app. --app takes a class name (which must | ||||||||||||||||||||||||||||||||||||||||||
| 140 | # provide ->queue) or a file (which must return a Punk::Queue) - the file | ||||||||||||||||||||||||||||||||||||||||||
| 141 | # form is how a worker gets its task registry before phase 8 wires the | ||||||||||||||||||||||||||||||||||||||||||
| 142 | # Punk plugin. | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 68 | ▶ | sub _queue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_queue: called CC=23 SCAR=38.6
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 68 | my ($opt) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 145 | 68 | ▶ | if (defined $opt->{app} && length $opt->{app}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $opt->{"app"} and length $opt->{"app"}
MC/DC50%1/2
defined $opt->{"app"} and length $opt->{"app"}
defined $opt->{"app"}
length $opt->{"app"}
Truth table66%2/3
A and B
A= defined $opt->{"app"}B= length $opt->{"app"}
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 37 | my $app = $opt->{app}; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 37 | ▶ | if (-f $app) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 35 | my $q = do $app; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 35 | ▶ | if (!(ref $q && eval { $q->isa('Punk::Queue') })) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $q and eval {
do {
$q->isa("Punk::Queue")
}
}
MC/DC50%1/2
ref $q and eval {
do {
$q->isa("Punk::Queue")
}
}
ref $q
eval {
do {
$q->isa("Punk::Queue")
}
}
Truth table66%2/3
A and B
A= ref $qB= eval {
do {
$q->isa("Punk::Queue")
}
}
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | ▶ | print STDERR defined $q | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$@ || $!
MC/DC0%0/2
$@ || $!
$@
$!
Truth table33%1/3
A || B
A= $@B= $!
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | ? "punk-queue: $app did not return a Punk::Queue\n" | ||||||||||||||||||||||||||||||||||||||||||
| 152 | : "punk-queue: could not load $app: " . ($@ || $!) . "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 34 | return $q; | |||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 2 | (my $file = "$app.pm") =~ s{::}{/}g; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 2 | my $loaded = eval { require $file; 1 }; | |||||||||||||||||||||||||||||||||||||||||
| 159 | # a failed require only matters when the class is genuinely absent - | ||||||||||||||||||||||||||||||||||||||||||
| 160 | # an already-compiled class (a preloaded app, a test) has no file | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | ▶ | if (!$loaded && !$app->can('punk_app') && !$app->can('queue')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$loaded or $app->can("punk_app") or $app->can("queue")
$loaded or $app->can("punk_app")
MC/DC0%0/3
$loaded or $app->can("punk_app") or $app->can("queue")
$loaded
$app->can("punk_app")
$app->can("queue")
Truth table50%2/4
A or B or C
A= $loadedB= $app->can("punk_app")C= $app->can("queue")
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | print STDERR "punk-queue: could not load $app: $@"; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | # A Punk application class: compile it (task targets and cron | ||||||||||||||||||||||||||||||||||||||||||
| 166 | # declarations only resolve at to_app) and take the queue from the | ||||||||||||||||||||||||||||||||||||||||||
| 167 | # plugin's state. Calling $app->queue here would land in the `queue` | ||||||||||||||||||||||||||||||||||||||||||
| 168 | # KEYWORD's declaration form - it would register a queue named after | ||||||||||||||||||||||||||||||||||||||||||
| 169 | # the class and return undef, which is the silent-exit-2 bug this | ||||||||||||||||||||||||||||||||||||||||||
| 170 | # branch replaces. Every failure now says what to do. | ||||||||||||||||||||||||||||||||||||||||||
| 171 | 2 | ▶ | if ($app->can('punk_app')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | ▶ | unless (eval { require Punk::Plugin::Queue; 1 }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | print STDERR "punk-queue: $app is a Punk application but " | |||||||||||||||||||||||||||||||||||||||||
| 174 | . "Punk::Plugin::Queue is not installed\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | # a second to_app croaks 'already compiled' - that one is fine | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 1 | eval { $app->to_app }; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | ▶ | if ($@ && $@ !~ /already compiled/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$@ and not $@ =~ /already compiled/
MC/DC0%0/2
$@ and not $@ =~ /already compiled/
$@
not $@ =~ /already compiled/
Truth table33%1/3
A and not(B)
A= $@B= not $@ =~ /already compiled/
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | print STDERR "punk-queue: $app failed to compile: $@"; | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | my $state = Punk::Plugin::Queue->state_for($app); | |||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | ▶ | my $q = $state && $state->{queue}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$state && $state->{'queue'}
MC/DC0%0/2
$state && $state->{'queue'}
$state
$state->{'queue'}
Truth table33%1/3
A && B
A= $stateB= $state->{'queue'}
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | ▶ | unless ($q) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | print STDERR "punk-queue: $app compiled but the Queue " | |||||||||||||||||||||||||||||||||||||||||
| 187 | . "plugin never registered a queue - is " | ||||||||||||||||||||||||||||||||||||||||||
| 188 | . "`plugin 'Queue'` (and anything gating it) " | ||||||||||||||||||||||||||||||||||||||||||
| 189 | . "active in that class?\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | return $q; | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | ▶ | if (!$app->can('queue')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 1 | print STDERR "punk-queue: $app has no queue() method\n"; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my $q = $app->queue; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | unless (ref $q && eval { $q->isa('Punk::Queue') }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $q and eval {
do {
$q->isa("Punk::Queue")
}
}
MC/DC0%0/2
ref $q and eval {
do {
$q->isa("Punk::Queue")
}
}
ref $q
eval {
do {
$q->isa("Punk::Queue")
}
}
Truth table0%0/3
A and B
A= ref $qB= eval {
do {
$q->isa("Punk::Queue")
}
}
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | print STDERR "punk-queue: $app->queue did not return a " | |||||||||||||||||||||||||||||||||||||||||
| 201 | . "Punk::Queue\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | return $q; | |||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 31 | ▶ | if (defined $opt->{dsn} && length $opt->{dsn}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $opt->{"dsn"} and length $opt->{"dsn"}
MC/DC50%1/2
defined $opt->{"dsn"} and length $opt->{"dsn"}
defined $opt->{"dsn"}
length $opt->{"dsn"}
Truth table66%2/3
A and B
A= defined $opt->{"dsn"}B= length $opt->{"dsn"}
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 30 | my $q = eval { Punk::Queue->new(dsn => $opt->{dsn}) }; | |||||||||||||||||||||||||||||||||||||||||
| 208 | 30 | ▶ | print STDERR "punk-queue: $@" if !$q; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 30 | return $q; | |||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | print STDERR "punk-queue: need --dsn or --app\n"; | |||||||||||||||||||||||||||||||||||||||||
| 212 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 6 | ▶ | sub _json { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_json: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | 6 | my ($data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 217 | 6 | require File::Raw::JSON; | |||||||||||||||||||||||||||||||||||||||||
| 218 | 6 | print File::Raw::JSON::file_json_encode($data, canonical => 1), "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 6 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 8 | ▶ | sub _epoch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_epoch: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 8 | my ($t) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 224 | 8 | ▶ | return '-' unless defined $t; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 7 | my @lt = localtime int $t; | |||||||||||||||||||||||||||||||||||||||||
| 226 | 7 | return sprintf '%04d-%02d-%02d %02d:%02d:%02d', | |||||||||||||||||||||||||||||||||||||||||
| 227 | $lt[5] + 1900, $lt[4] + 1, @lt[3, 2, 1, 0]; | ||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | ▶ | sub _table { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_table: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | my ($cols, $rows) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | my @w = map { length } @$cols; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 1 | for my $r (@$rows) { | |||||||||||||||||||||||||||||||||||||||||
| 234 | $w[$_] = length $r->[$_] > $w[$_] ? length $r->[$_] : $w[$_] | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 1 | ▶ | for 0 .. $#$cols; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 1 | my $fmt = join(' ', map { "%-${_}s" } @w) . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 238 | 1 | printf $fmt, @$cols; | |||||||||||||||||||||||||||||||||||||||||
| 239 | 1 | printf $fmt, @$_ for @$rows; | |||||||||||||||||||||||||||||||||||||||||
| 240 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | # ---- worker ----------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 34 | ▶ | sub worker { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
worker: called CC=13 SCAR=26.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 34 | my (@argv) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 34 | my %opt = (queue => [], task => []); | |||||||||||||||||||||||||||||||||||||||||
| 248 | _getopt(\@argv, | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 'dsn=s' => \$opt{dsn}, | ||||||||||||||||||||||||||||||||||||||||||
| 250 | 'app=s' => \$opt{app}, | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 'queue|q=s@' => $opt{queue}, | ||||||||||||||||||||||||||||||||||||||||||
| 252 | 'task|t=s@' => $opt{task}, | ||||||||||||||||||||||||||||||||||||||||||
| 253 | 'jobs|j=i' => \$opt{jobs}, | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 'interval=f' => \$opt{interval}, | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 'max-jobs=i' => \$opt{max_jobs}, | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 'graceful-timeout=f' => \$opt{graceful}, | ||||||||||||||||||||||||||||||||||||||||||
| 257 | 'fail-fast' => \$opt{fail_fast}, | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 'no-scheduler' => \$opt{no_scheduler}, | ||||||||||||||||||||||||||||||||||||||||||
| 259 | 34 | ▶ | ) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 34 | ▶ | my $q = _queue(\%opt) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | my @queues = map { split /,/ } @{ $opt{queue} }; | |||||||||||||||||||||||||||||||||||||||||
| 263 | 33 | my @tasks = map { split /,/ } @{ $opt{task} }; | |||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 33 | my %wopts; | |||||||||||||||||||||||||||||||||||||||||
| 266 | 33 | ▶ | $wopts{queues} = \@queues if @queues; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 33 | ▶ | $wopts{tasks} = \@tasks if @tasks; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | 33 | ▶ | $wopts{interval} = $opt{interval} if defined $opt{interval}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | 33 | ▶ | $wopts{max_jobs} = $opt{max_jobs} if defined $opt{max_jobs}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | # The oneshot seam runs a single in-process worker - no fork, no | ||||||||||||||||||||||||||||||||||||||||||
| 272 | # supervisor - which is how t/ drives a real worker without hanging. | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 33 | ▶ | if ($ENV{PUNK_QUEUE_ONESHOT}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 12 | my $n = $q->worker(%wopts)->run; | |||||||||||||||||||||||||||||||||||||||||
| 275 | 12 | ▶ | return $n ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | return Punk::Queue::Supervisor->run($q, | ||||||||||||||||||||||||||||||||||||||||||
| 279 | workers => $opt{jobs} // 1, | ||||||||||||||||||||||||||||||||||||||||||
| 280 | graceful_timeout => $opt{graceful} // 60, | ||||||||||||||||||||||||||||||||||||||||||
| 281 | fail_fast => $opt{fail_fast} ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 21 | ▶ | scheduler => $opt{no_scheduler} ? 0 : 1, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition75%3/4
$opt{"jobs"} // 1
$opt{"graceful"} // 60
MC/DC100%1/1
$opt{"jobs"} // 1
$opt{"jobs"}
MC/DC0%0/1
$opt{"graceful"} // 60
$opt{"graceful"}
Truth table100%2/2
A
A= $opt{"jobs"}
Truth table50%1/2
A
A= $opt{"graceful"}
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | %wopts, | ||||||||||||||||||||||||||||||||||||||||||
| 284 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | # ---- enqueue ---------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | # Bare args are JSON when they parse as JSON, strings otherwise; --json | ||||||||||||||||||||||||||||||||||||||||||
| 290 | # passes the whole array unambiguously. Decoded through frj, so the CLI | ||||||||||||||||||||||||||||||||||||||||||
| 291 | # and the app agree byte for byte on what the task receives. | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 3 | ▶ | sub _parse_arg { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_arg: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 3 | my ($raw) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 294 | 3 | require File::Raw::JSON; | |||||||||||||||||||||||||||||||||||||||||
| 295 | 3 | my $v = eval { File::Raw::JSON::file_json_decode($raw) }; | |||||||||||||||||||||||||||||||||||||||||
| 296 | 3 | ▶ | return $@ ? $raw : $v; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 4 | ▶ | sub enqueue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enqueue: called CC=11 SCAR=24.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 4 | my (@argv) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 4 | my %opt = (parent => []); | |||||||||||||||||||||||||||||||||||||||||
| 302 | _getopt(\@argv, | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 'dsn=s' => \$opt{dsn}, | ||||||||||||||||||||||||||||||||||||||||||
| 304 | 'app=s' => \$opt{app}, | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 'queue|q=s' => \$opt{queue}, | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 'priority|p=i' => \$opt{priority}, | ||||||||||||||||||||||||||||||||||||||||||
| 307 | 'delay=f' => \$opt{delay}, | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 'attempts=i' => \$opt{attempts}, | ||||||||||||||||||||||||||||||||||||||||||
| 309 | 'expire=f' => \$opt{expire}, | ||||||||||||||||||||||||||||||||||||||||||
| 310 | 'timeout=f' => \$opt{timeout}, | ||||||||||||||||||||||||||||||||||||||||||
| 311 | 'parent=i@' => $opt{parent}, | ||||||||||||||||||||||||||||||||||||||||||
| 312 | 'lax' => \$opt{lax}, | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 'unique=s' => \$opt{unique}, | ||||||||||||||||||||||||||||||||||||||||||
| 314 | 'json=s' => \$opt{json}, | ||||||||||||||||||||||||||||||||||||||||||
| 315 | 4 | ▶ | ) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 4 | my $task = shift @argv; | |||||||||||||||||||||||||||||||||||||||||
| 318 | 4 | ▶ | if (!defined $task) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | print STDERR "punk-queue: enqueue needs a task name\n"; | |||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | return 2; | |||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||
| 322 | 4 | ▶ | my $q = _queue(\%opt) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 4 | my $args; | |||||||||||||||||||||||||||||||||||||||||
| 325 | 4 | ▶ | if (defined $opt{json}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | 2 | require File::Raw::JSON; | |||||||||||||||||||||||||||||||||||||||||
| 327 | 2 | $args = eval { File::Raw::JSON::file_json_decode($opt{json}) }; | |||||||||||||||||||||||||||||||||||||||||
| 328 | 2 | ▶ | if ($@ || ref $args ne 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$@ or ref $args ne "ARRAY"
MC/DC50%1/2
$@ or ref $args ne "ARRAY"
$@
ref $args ne "ARRAY"
Truth table66%2/3
A or B
A= $@B= ref $args ne "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | 1 | print STDERR "punk-queue: --json must be a JSON array\n"; | |||||||||||||||||||||||||||||||||||||||||
| 330 | 1 | return 2; | |||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||
| 333 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 334 | 2 | $args = [ map { _parse_arg($_) } @argv ]; | |||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | 3 | my %eopts; | |||||||||||||||||||||||||||||||||||||||||
| 338 | $eopts{$_} = $opt{$_} | ||||||||||||||||||||||||||||||||||||||||||
| 339 | 3 | for grep { defined $opt{$_} } | |||||||||||||||||||||||||||||||||||||||||
| 340 | qw(queue priority delay attempts expire timeout unique); | ||||||||||||||||||||||||||||||||||||||||||
| 341 | 3 | ▶ | $eopts{lax} = 1 if $opt{lax}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | 3 | ▶ | $eopts{parents} = $opt{parent} if @{ $opt{parent} }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | 3 | my $id = eval { $q->enqueue($task, $args, %eopts) }; | |||||||||||||||||||||||||||||||||||||||||
| 345 | 3 | ▶ | if (!$id) { print STDERR "punk-queue: $@"; return 1; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 2 | print "$id\n"; | |||||||||||||||||||||||||||||||||||||||||
| 347 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | # ---- job (read and write) --------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | 11 | ▶ | sub job { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
job: called CC=26 SCAR=36.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | 11 | my (@argv) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 354 | 11 | my %opt; | |||||||||||||||||||||||||||||||||||||||||
| 355 | _getopt(\@argv, | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 'dsn=s' => \$opt{dsn}, | ||||||||||||||||||||||||||||||||||||||||||
| 357 | 'app=s' => \$opt{app}, | ||||||||||||||||||||||||||||||||||||||||||
| 358 | 'retry' => \$opt{retry}, | ||||||||||||||||||||||||||||||||||||||||||
| 359 | 'remove' => \$opt{remove}, | ||||||||||||||||||||||||||||||||||||||||||
| 360 | 'fail=s' => \$opt{fail}, | ||||||||||||||||||||||||||||||||||||||||||
| 361 | 'delay=f' => \$opt{delay}, | ||||||||||||||||||||||||||||||||||||||||||
| 362 | 'priority=i' => \$opt{priority}, | ||||||||||||||||||||||||||||||||||||||||||
| 363 | 'queue=s' => \$opt{queue}, | ||||||||||||||||||||||||||||||||||||||||||
| 364 | 'log' => \$opt{log}, | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 'json' => \$opt{json}, | ||||||||||||||||||||||||||||||||||||||||||
| 366 | 11 | ▶ | ) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | 11 | my @ids = grep { /^\d+$/ } @argv; | |||||||||||||||||||||||||||||||||||||||||
| 369 | 11 | ▶ | if (!@ids) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | print STDERR "punk-queue: job needs at least one numeric id\n"; | |||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | return 2; | |||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 11 | my $writes = grep { defined } @opt{qw(retry remove fail)}; | |||||||||||||||||||||||||||||||||||||||||
| 374 | 11 | ▶ | if ($writes > 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | 1 | print STDERR "punk-queue: --retry, --remove and --fail are exclusive\n"; | |||||||||||||||||||||||||||||||||||||||||
| 376 | 1 | return 2; | |||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 378 | 10 | ▶ | my $q = _queue(\%opt) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 10 | my $rc = 0; | |||||||||||||||||||||||||||||||||||||||||
| 381 | 10 | for my $id (@ids) { | |||||||||||||||||||||||||||||||||||||||||
| 382 | 13 | my $info = $q->job_info($id); | |||||||||||||||||||||||||||||||||||||||||
| 383 | 13 | ▶ | if (!$info) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | 2 | print STDERR "punk-queue: no job $id\n"; | |||||||||||||||||||||||||||||||||||||||||
| 385 | 2 | $rc = 1; | |||||||||||||||||||||||||||||||||||||||||
| 386 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | 11 | ▶ | if ($opt{retry}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | 4 | my %r; | |||||||||||||||||||||||||||||||||||||||||
| 391 | $r{$_} = $opt{$_} | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 4 | for grep { defined $opt{$_} } qw(delay priority queue); | |||||||||||||||||||||||||||||||||||||||||
| 393 | 4 | my $ok = $q->retry_job($id, $info->{retries}, \%r); | |||||||||||||||||||||||||||||||||||||||||
| 394 | 4 | ▶ | print $ok ? "job $id retried\n" : "job $id not retried\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | 4 | ▶ | $rc = 1 unless $ok; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 397 | elsif ($opt{remove}) { | ||||||||||||||||||||||||||||||||||||||||||
| 398 | 3 | my $ok = $q->remove_job($id); | |||||||||||||||||||||||||||||||||||||||||
| 399 | 3 | ▶ | print $ok ? "job $id removed\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 400 | : "job $id not removed (active? retry it first)\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 401 | 3 | ▶ | $rc = 1 unless $ok; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||
| 403 | elsif (defined $opt{fail}) { | ||||||||||||||||||||||||||||||||||||||||||
| 404 | 1 | my $ok = $q->fail_job($id, $info->{retries}, $opt{fail}); | |||||||||||||||||||||||||||||||||||||||||
| 405 | 1 | ▶ | print $ok ? "job $id failed\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | : "job $id not failed (not active)\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 407 | 1 | ▶ | $rc = 1 unless $ok; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||
| 409 | elsif ($opt{log}) { | ||||||||||||||||||||||||||||||||||||||||||
| 410 | 2 | my $log = $q->job_log($id); | |||||||||||||||||||||||||||||||||||||||||
| 411 | 2 | ▶ | if ($opt{json}) { _json($log) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | elsif (!@$log) { print "job $id has no log lines\n" } | |||||||||||||||||||||||||||||||||||||||||
| 413 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 414 | printf "%s %-5s %s\n", | ||||||||||||||||||||||||||||||||||||||||||
| 415 | _epoch($_->{created}), $_->{level}, $_->{message} | ||||||||||||||||||||||||||||||||||||||||||
| 416 | 1 | for @$log; | |||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||
| 419 | elsif ($opt{json}) { | ||||||||||||||||||||||||||||||||||||||||||
| 420 | 1 | _json($info); | |||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||
| 422 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | for my $k (qw(id task queue state priority retries attempts)) { | |||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | printf "%-9s %s\n", $k, $info->{$k} // '-'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$info->{$k} // "-"
MC/DC0%0/1
$info->{$k} // "-"
$info->{$k}
Truth table0%0/2
A
A= $info->{$k}
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||
| 426 | printf "%-9s %s\n", $_, _epoch($info->{$_}) | ||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | for qw(created delayed started finished); | |||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | require File::Raw::JSON; | |||||||||||||||||||||||||||||||||||||||||
| 429 | printf "%-9s %s\n", 'args', | ||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | File::Raw::JSON::file_json_encode($info->{args}); | |||||||||||||||||||||||||||||||||||||||||
| 431 | printf "%-9s %s\n", 'result', | ||||||||||||||||||||||||||||||||||||||||||
| 432 | defined $info->{result} | ||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | ? File::Raw::JSON::file_json_encode($info->{result}) : '-'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | printf "%-9s %s\n", 'notes', | ||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | File::Raw::JSON::file_json_encode($info->{notes}); | |||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 438 | 10 | return $rc; | |||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | # ---- lists and stats -------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | 3 | ▶ | sub jobs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
jobs: called CC=7 SCAR=22.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 444 | 3 | my (@argv) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 445 | 3 | my %opt; | |||||||||||||||||||||||||||||||||||||||||
| 446 | _getopt(\@argv, | ||||||||||||||||||||||||||||||||||||||||||
| 447 | 'dsn=s' => \$opt{dsn}, | ||||||||||||||||||||||||||||||||||||||||||
| 448 | 'app=s' => \$opt{app}, | ||||||||||||||||||||||||||||||||||||||||||
| 449 | 'state=s' => \$opt{state}, | ||||||||||||||||||||||||||||||||||||||||||
| 450 | 'queue=s' => \$opt{queue}, | ||||||||||||||||||||||||||||||||||||||||||
| 451 | 'task=s' => \$opt{task}, | ||||||||||||||||||||||||||||||||||||||||||
| 452 | 'worker=i' => \$opt{worker}, | ||||||||||||||||||||||||||||||||||||||||||
| 453 | 'limit=i' => \$opt{limit}, | ||||||||||||||||||||||||||||||||||||||||||
| 454 | 'offset=i' => \$opt{offset}, | ||||||||||||||||||||||||||||||||||||||||||
| 455 | 'json' => \$opt{json}, | ||||||||||||||||||||||||||||||||||||||||||
| 456 | 3 | ▶ | ) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 457 | 3 | ▶ | my $q = _queue(\%opt) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | 2 | my %f; | |||||||||||||||||||||||||||||||||||||||||
| 460 | $f{$_} = $opt{$_} | ||||||||||||||||||||||||||||||||||||||||||
| 461 | 2 | for grep { defined $opt{$_} } qw(state queue task worker); | |||||||||||||||||||||||||||||||||||||||||
| 462 | 2 | ▶ | my $r = $q->list_jobs($opt{offset} // 0, $opt{limit} // 0, \%f); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
$opt{"offset"} // 0
$opt{"limit"} // 0
MC/DC0%0/1
$opt{"offset"} // 0
$opt{"offset"}
MC/DC0%0/1
$opt{"limit"} // 0
$opt{"limit"}
Truth table50%1/2
A
A= $opt{"offset"}
Truth table50%1/2
A
A= $opt{"limit"}
| |||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | 2 | ▶ | return _json($r) if $opt{json}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | print "total: $r->{total}\n"; | |||||||||||||||||||||||||||||||||||||||||
| 466 | return _table( | ||||||||||||||||||||||||||||||||||||||||||
| 467 | [qw(id task queue state pri try created)], | ||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | [ map { [ @{$_}{qw(id task queue state priority)}, | |||||||||||||||||||||||||||||||||||||||||
| 469 | "$_->{retries}/$_->{attempts}", | ||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | _epoch($_->{created}) ] } @{ $r->{jobs} } ]); | |||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | 1 | ▶ | sub workers { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
workers: called CC=6 SCAR=24.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 474 | 1 | my (@argv) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 475 | 1 | my %opt; | |||||||||||||||||||||||||||||||||||||||||
| 476 | _getopt(\@argv, | ||||||||||||||||||||||||||||||||||||||||||
| 477 | 'dsn=s' => \$opt{dsn}, | ||||||||||||||||||||||||||||||||||||||||||
| 478 | 'app=s' => \$opt{app}, | ||||||||||||||||||||||||||||||||||||||||||
| 479 | 'role=s' => \$opt{role}, | ||||||||||||||||||||||||||||||||||||||||||
| 480 | 'json' => \$opt{json}, | ||||||||||||||||||||||||||||||||||||||||||
| 481 | 1 | ▶ | ) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | 1 | ▶ | my $q = _queue(\%opt) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | my $r = $q->list_workers(0, 0, | ||||||||||||||||||||||||||||||||||||||||||
| 485 | 1 | ▶ | defined $opt{role} ? { role => $opt{role} } : undef); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | 1 | ▶ | return _json($r) if $opt{json}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | print "total: $r->{total}\n"; | |||||||||||||||||||||||||||||||||||||||||
| 488 | return _table( | ||||||||||||||||||||||||||||||||||||||||||
| 489 | [qw(id host pid role queues notified)], | ||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | [ map { [ @{$_}{qw(id host pid role)}, | |||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | join(',', @{ $_->{queues} || [] }), | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_->{'queues'} || []
MC/DC0%0/1
$_->{'queues'} || []
$_->{'queues'}
Truth table0%0/2
A
A= $_->{'queues'}
| |||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | _epoch($_->{notified}) ] } @{ $r->{workers} } ]); | |||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | 6 | ▶ | sub stats { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stats: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 496 | 6 | my (@argv) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 497 | 6 | my %opt; | |||||||||||||||||||||||||||||||||||||||||
| 498 | _getopt(\@argv, | ||||||||||||||||||||||||||||||||||||||||||
| 499 | 'dsn=s' => \$opt{dsn}, | ||||||||||||||||||||||||||||||||||||||||||
| 500 | 'app=s' => \$opt{app}, | ||||||||||||||||||||||||||||||||||||||||||
| 501 | 'json' => \$opt{json}, | ||||||||||||||||||||||||||||||||||||||||||
| 502 | 6 | ▶ | ) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 503 | 6 | ▶ | my $q = _queue(\%opt) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | 4 | my $s = $q->stats; | |||||||||||||||||||||||||||||||||||||||||
| 506 | 4 | ▶ | return _json($s) if $opt{json}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | printf "%-15s %s\n", $_, $s->{$_} | ||||||||||||||||||||||||||||||||||||||||||
| 508 | 3 | for qw(inactive_jobs active_jobs failed_jobs finished_jobs | |||||||||||||||||||||||||||||||||||||||||
| 509 | delayed_jobs total_jobs workers schema_version); | ||||||||||||||||||||||||||||||||||||||||||
| 510 | 3 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||
| 513 | # ---- repair, locks, broadcast ----------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | sub repair { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repair: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | my (@argv) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | my %opt; | |||||||||||||||||||||||||||||||||||||||||
| 518 | _getopt(\@argv, | ||||||||||||||||||||||||||||||||||||||||||
| 519 | 'dsn=s' => \$opt{dsn}, | ||||||||||||||||||||||||||||||||||||||||||
| 520 | 'app=s' => \$opt{app}, | ||||||||||||||||||||||||||||||||||||||||||
| 521 | 'deep' => \$opt{deep}, | ||||||||||||||||||||||||||||||||||||||||||
| 522 | 'json' => \$opt{json}, | ||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | ) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | my $q = _queue(\%opt) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | ▶ | my $r = $q->repair($opt{deep} ? (deep => 1) : ()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | return _json($r) if $opt{json}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | printf "%-20s %d\n", $_, $r->{$_} for sort keys %$r; | |||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | sub locks { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locks: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | my (@argv) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | my %opt; | |||||||||||||||||||||||||||||||||||||||||
| 535 | _getopt(\@argv, | ||||||||||||||||||||||||||||||||||||||||||
| 536 | 'dsn=s' => \$opt{dsn}, | ||||||||||||||||||||||||||||||||||||||||||
| 537 | 'app=s' => \$opt{app}, | ||||||||||||||||||||||||||||||||||||||||||
| 538 | 'name=s' => \$opt{name}, | ||||||||||||||||||||||||||||||||||||||||||
| 539 | 'json' => \$opt{json}, | ||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | ) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | ▶ | my $q = _queue(\%opt) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||
| 543 | my $r = $q->list_locks(0, 0, | ||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | defined $opt{name} ? { name => $opt{name} } : undef); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | ▶ | return _json($r) if $opt{json}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | print "total: $r->{total}\n"; | |||||||||||||||||||||||||||||||||||||||||
| 547 | return _table( | ||||||||||||||||||||||||||||||||||||||||||
| 548 | [qw(id name owner expires)], | ||||||||||||||||||||||||||||||||||||||||||
| 549 | [ map { [ $_->{id}, $_->{name}, $_->{owner} // '-', | ||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | _epoch($_->{expires}) ] } @{ $r->{locks} } ]); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_->{"owner"} // "-"
MC/DC0%0/1
$_->{"owner"} // "-"
$_->{"owner"}
Truth table0%0/2
A
A= $_->{"owner"}
| |||||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | sub lock { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lock: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | my (@argv) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | my %opt; | |||||||||||||||||||||||||||||||||||||||||
| 556 | _getopt(\@argv, | ||||||||||||||||||||||||||||||||||||||||||
| 557 | 'dsn=s' => \$opt{dsn}, | ||||||||||||||||||||||||||||||||||||||||||
| 558 | 'app=s' => \$opt{app}, | ||||||||||||||||||||||||||||||||||||||||||
| 559 | 'duration=f' => \$opt{duration}, | ||||||||||||||||||||||||||||||||||||||||||
| 560 | 'limit=i' => \$opt{limit}, | ||||||||||||||||||||||||||||||||||||||||||
| 561 | 'owner=i' => \$opt{owner}, | ||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | ) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | my $name = shift @argv; | |||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | if (!defined $name) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | print STDERR "punk-queue: lock needs a name\n"; | |||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | return 2; | |||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | ▶ | my $q = _queue(\%opt) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 569 | my $got = $q->lock($name, $opt{duration} // 60, | ||||||||||||||||||||||||||||||||||||||||||
| 570 | (defined $opt{limit} ? (limit => $opt{limit}) : ()), | ||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | (defined $opt{owner} ? (owner => $opt{owner}) : ())); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/2
$opt{"duration"} // 60
MC/DC0%0/1
$opt{"duration"} // 60
$opt{"duration"}
Truth table0%0/2
A
A= $opt{"duration"}
| |||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | ▶ | print $got ? "acquired\n" : "held\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | return $got ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | sub unlock { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unlock: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | my (@argv) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | my %opt; | |||||||||||||||||||||||||||||||||||||||||
| 579 | _getopt(\@argv, | ||||||||||||||||||||||||||||||||||||||||||
| 580 | 'dsn=s' => \$opt{dsn}, | ||||||||||||||||||||||||||||||||||||||||||
| 581 | 'app=s' => \$opt{app}, | ||||||||||||||||||||||||||||||||||||||||||
| 582 | 'owner=i' => \$opt{owner}, | ||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | ) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | my $name = shift @argv; | |||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | ▶ | if (!defined $name) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | print STDERR "punk-queue: unlock needs a name\n"; | |||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | return 2; | |||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | ▶ | my $q = _queue(\%opt) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 590 | my $ok = $q->unlock($name, | ||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | ▶ | defined $opt{owner} ? $opt{owner} : ()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | print $ok ? "released\n" : "not held\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | ▶ | return $ok ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | ▶ | sub broadcast { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
broadcast: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | my (@argv) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | my %opt = (worker => []); | |||||||||||||||||||||||||||||||||||||||||
| 599 | _getopt(\@argv, | ||||||||||||||||||||||||||||||||||||||||||
| 600 | 'dsn=s' => \$opt{dsn}, | ||||||||||||||||||||||||||||||||||||||||||
| 601 | 'app=s' => \$opt{app}, | ||||||||||||||||||||||||||||||||||||||||||
| 602 | 'worker=i@' => $opt{worker}, | ||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | ) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | my $cmd = shift @argv; | |||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | ▶ | if (!defined $cmd) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | print STDERR "punk-queue: broadcast needs a command\n"; | |||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | return 2; | |||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | ▶ | my $q = _queue(\%opt) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 610 | my $n = $q->broadcast($cmd, [@argv], | ||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | ▶ | @{ $opt{worker} } ? $opt{worker} : ()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | print "sent to $n worker(s)\n"; | |||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | ▶ | return $n ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||
| 616 | # ---- cron ------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||
| 618 | 1 | ▶ | sub crons { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
crons: called CC=5 SCAR=16.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 619 | 1 | my (@argv) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 620 | 1 | my %opt; | |||||||||||||||||||||||||||||||||||||||||
| 621 | _getopt(\@argv, | ||||||||||||||||||||||||||||||||||||||||||
| 622 | 'dsn=s' => \$opt{dsn}, | ||||||||||||||||||||||||||||||||||||||||||
| 623 | 'app=s' => \$opt{app}, | ||||||||||||||||||||||||||||||||||||||||||
| 624 | 'json' => \$opt{json}, | ||||||||||||||||||||||||||||||||||||||||||
| 625 | 1 | ▶ | ) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 626 | 1 | ▶ | my $q = _queue(\%opt) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||
| 628 | 1 | my $r = $q->list_crons; | |||||||||||||||||||||||||||||||||||||||||
| 629 | 1 | ▶ | return _json($r) if $opt{json}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 630 | 1 | print "total: $r->{total}\n"; | |||||||||||||||||||||||||||||||||||||||||
| 631 | return _table( | ||||||||||||||||||||||||||||||||||||||||||
| 632 | [qw(name expr tz enabled next_run last_run task)], | ||||||||||||||||||||||||||||||||||||||||||
| 633 | [ map { [ $_->{name}, $_->{expr}, $_->{tz}, | ||||||||||||||||||||||||||||||||||||||||||
| 634 | $_->{enabled} ? 'yes' : 'no', | ||||||||||||||||||||||||||||||||||||||||||
| 635 | _epoch($_->{next_run}), _epoch($_->{last_run}), | ||||||||||||||||||||||||||||||||||||||||||
| 636 | 1 | ▶ | $_->{task} ] } @{ $r->{crons} } ]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||
| 639 | 6 | ▶ | sub cron { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cron: called CC=20 SCAR=31.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 640 | 6 | my (@argv) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 641 | 6 | my $verb = shift @argv; | |||||||||||||||||||||||||||||||||||||||||
| 642 | 6 | ▶ | if (!defined $verb) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | print STDERR "punk-queue: cron needs run|enable|disable|next\n"; | |||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | return 2; | |||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||
| 647 | # `cron next` is pure arithmetic - no database, no --dsn | ||||||||||||||||||||||||||||||||||||||||||
| 648 | 6 | ▶ | if ($verb eq 'next') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 649 | 2 | my %opt; | |||||||||||||||||||||||||||||||||||||||||
| 650 | _getopt(\@argv, | ||||||||||||||||||||||||||||||||||||||||||
| 651 | 'tz=s' => \$opt{tz}, | ||||||||||||||||||||||||||||||||||||||||||
| 652 | 'count=i' => \$opt{count}, | ||||||||||||||||||||||||||||||||||||||||||
| 653 | 2 | ▶ | ) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 654 | 2 | my $expr = shift @argv; | |||||||||||||||||||||||||||||||||||||||||
| 655 | 2 | ▶ | if (!defined $expr) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | print STDERR "punk-queue: cron next needs an expression\n"; | |||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | return 2; | |||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||
| 659 | 2 | my $err; | |||||||||||||||||||||||||||||||||||||||||
| 660 | { | ||||||||||||||||||||||||||||||||||||||||||
| 661 | 2 | local $@; | |||||||||||||||||||||||||||||||||||||||||
| 662 | 2 | ▶ | eval { Punk::Queue::Cron->check($expr, $opt{tz}); 1 } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 663 | or $err = $@; | ||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||
| 665 | 2 | ▶ | if (defined $err) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 666 | 1 | print STDERR "punk-queue: $err"; | |||||||||||||||||||||||||||||||||||||||||
| 667 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||
| 669 | 1 | my $from = time; | |||||||||||||||||||||||||||||||||||||||||
| 670 | 1 | ▶ | for (1 .. ($opt{count} // 10)) { | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opt{"count"} // 10
MC/DC0%0/1
$opt{"count"} // 10
$opt{"count"}
Truth table50%1/2
A
A= $opt{"count"}
| |||||||||||||||||||||||||||||||||||||||||||
| 671 | 3 | my $at = Punk::Queue::Cron->next_after($expr, $from, $opt{tz}); | |||||||||||||||||||||||||||||||||||||||||
| 672 | 3 | ▶ | last unless defined $at; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 673 | 3 | print _epoch($at), "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 674 | 3 | $from = $at; | |||||||||||||||||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||||||||||||||||
| 676 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||
| 679 | 4 | ▶ | if ($verb ne 'run' && $verb ne 'enable' && $verb ne 'disable') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$verb ne "run" and $verb ne "enable" and $verb ne "disable"
$verb ne "run" and $verb ne "enable"
MC/DC0%0/3
$verb ne "run" and $verb ne "enable" and $verb ne "disable"
$verb ne "run"
$verb ne "enable"
$verb ne "disable"
Truth table75%3/4
A and B and C
A= $verb ne "run"B= $verb ne "enable"C= $verb ne "disable"
| |||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | print STDERR "punk-queue: unknown cron action '$verb'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | return 2; | |||||||||||||||||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||
| 684 | 4 | my %opt; | |||||||||||||||||||||||||||||||||||||||||
| 685 | _getopt(\@argv, | ||||||||||||||||||||||||||||||||||||||||||
| 686 | 'dsn=s' => \$opt{dsn}, | ||||||||||||||||||||||||||||||||||||||||||
| 687 | 'app=s' => \$opt{app}, | ||||||||||||||||||||||||||||||||||||||||||
| 688 | 4 | ▶ | ) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 689 | 4 | my $name = shift @argv; | |||||||||||||||||||||||||||||||||||||||||
| 690 | 4 | ▶ | if (!defined $name) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | print STDERR "punk-queue: cron $verb needs a name\n"; | |||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | return 2; | |||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||
| 694 | 4 | ▶ | my $q = _queue(\%opt) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 695 | 4 | my $info = $q->cron_info($name); | |||||||||||||||||||||||||||||||||||||||||
| 696 | 4 | ▶ | if (!$info) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 697 | 1 | print STDERR "punk-queue: no cron named '$name'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 698 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 699 | } | ||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||
| 701 | # fire now, schedule untouched - the CLI twin of the UI's run button | ||||||||||||||||||||||||||||||||||||||||||
| 702 | 3 | ▶ | if ($verb eq 'run') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 703 | my $id = $q->enqueue($info->{task}, $info->{args}, | ||||||||||||||||||||||||||||||||||||||||||
| 704 | queue => $info->{queue}, | ||||||||||||||||||||||||||||||||||||||||||
| 705 | priority => $info->{priority}, | ||||||||||||||||||||||||||||||||||||||||||
| 706 | 1 | attempts => $info->{attempts}); | |||||||||||||||||||||||||||||||||||||||||
| 707 | 1 | print "enqueued job $id\n"; | |||||||||||||||||||||||||||||||||||||||||
| 708 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||
| 711 | 2 | ▶ | $q->enable_cron($name, $verb eq 'enable' ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 712 | 2 | ▶ | print $verb eq 'enable' ? "enabled\n" : "disabled\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 713 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 714 | } | ||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||
| 716 | # ---- schema ----------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||
| 718 | 4 | ▶ | sub migrate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
migrate: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 719 | 4 | my (@argv) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 720 | 4 | my %opt; | |||||||||||||||||||||||||||||||||||||||||
| 721 | _getopt(\@argv, | ||||||||||||||||||||||||||||||||||||||||||
| 722 | 'dsn=s' => \$opt{dsn}, | ||||||||||||||||||||||||||||||||||||||||||
| 723 | 'app=s' => \$opt{app}, | ||||||||||||||||||||||||||||||||||||||||||
| 724 | 'check' => \$opt{check}, | ||||||||||||||||||||||||||||||||||||||||||
| 725 | 4 | ▶ | ) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 726 | 4 | ▶ | my $q = _queue(\%opt) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||
| 728 | 4 | ▶ | if ($opt{check}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 729 | 2 | my ($have, $want) = | |||||||||||||||||||||||||||||||||||||||||
| 730 | ($q->schema_version, $q->backend->latest_version); | ||||||||||||||||||||||||||||||||||||||||||
| 731 | 2 | print "schema $have, latest $want\n"; | |||||||||||||||||||||||||||||||||||||||||
| 732 | 2 | ▶ | return $have >= $want ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||||||||||||||||
| 734 | 2 | my $v = $q->migrate; | |||||||||||||||||||||||||||||||||||||||||
| 735 | 2 | print "schema at $v\n"; | |||||||||||||||||||||||||||||||||||||||||
| 736 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 737 | } | ||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||
| 739 | 2 | ▶ | sub reset { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 740 | 2 | my (@argv) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 741 | 2 | my %opt; | |||||||||||||||||||||||||||||||||||||||||
| 742 | _getopt(\@argv, | ||||||||||||||||||||||||||||||||||||||||||
| 743 | 'dsn=s' => \$opt{dsn}, | ||||||||||||||||||||||||||||||||||||||||||
| 744 | 'app=s' => \$opt{app}, | ||||||||||||||||||||||||||||||||||||||||||
| 745 | 'yes' => \$opt{yes}, | ||||||||||||||||||||||||||||||||||||||||||
| 746 | 2 | ▶ | ) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 747 | 2 | ▶ | if (!$opt{yes}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 748 | 1 | print STDERR | |||||||||||||||||||||||||||||||||||||||||
| 749 | "punk-queue: reset deletes every job, worker, lock and cron; " | ||||||||||||||||||||||||||||||||||||||||||
| 750 | . "pass --yes to mean it\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 751 | 1 | return 2; | |||||||||||||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||||||||||||
| 753 | 1 | ▶ | my $q = _queue(\%opt) or return 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 754 | 1 | $q->reset; | |||||||||||||||||||||||||||||||||||||||||
| 755 | 1 | print "reset\n"; | |||||||||||||||||||||||||||||||||||||||||
| 756 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 757 | } | ||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||
| 759 | 70 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||
| 761 | __END__ | ||||||||||||||||||||||||||||||||||||||||||