Hello community, here is the log from the commit of package perl-Minion for openSUSE:Factory checked in at 2017-04-12 17:36:21 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Minion (Old) and /work/SRC/openSUSE:Factory/.perl-Minion.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Minion" Wed Apr 12 17:36:21 2017 rev:24 rq:486681 version:6.05 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Minion/perl-Minion.changes 2017-03-24 02:23:26.680867167 +0100 +++ /work/SRC/openSUSE:Factory/.perl-Minion.new/perl-Minion.changes 2017-04-12 18:17:21.048331110 +0200 @@ -1,0 +2,12 @@ +Fri Apr 7 06:12:47 UTC 2017 - [email protected] + +- updated to 6.05 + see /usr/share/doc/packages/perl-Minion/Changes + + 6.05 2017-04-03 + - Added support for sharing worker status information. + - Improved retry methods to allow for active jobs to be retried as well. + - Improved job command to show timestamps in RFC 3339 (1994-11-06T08:49:37Z) + format. + +------------------------------------------------------------------- Old: ---- Minion-6.04.tar.gz New: ---- Minion-6.05.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Minion.spec ++++++ --- /var/tmp/diff_new_pack.yHxk97/_old 2017-04-12 18:17:21.576256457 +0200 +++ /var/tmp/diff_new_pack.yHxk97/_new 2017-04-12 18:17:21.580255892 +0200 @@ -17,7 +17,7 @@ Name: perl-Minion -Version: 6.04 +Version: 6.05 Release: 0 %define cpan_name Minion Summary: Job queue @@ -30,8 +30,8 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: perl BuildRequires: perl-macros -BuildRequires: perl(Mojolicious) >= 6.0 -Requires: perl(Mojolicious) >= 6.0 +BuildRequires: perl(Mojolicious) >= 7.29 +Requires: perl(Mojolicious) >= 7.29 %{perl_requires} %description ++++++ Minion-6.04.tar.gz -> Minion-6.05.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Minion-6.04/Changes new/Minion-6.05/Changes --- old/Minion-6.04/Changes 2017-03-18 16:16:36.000000000 +0100 +++ new/Minion-6.05/Changes 2017-04-03 23:12:58.000000000 +0200 @@ -1,4 +1,10 @@ +6.05 2017-04-03 + - Added support for sharing worker status information. + - Improved retry methods to allow for active jobs to be retried as well. + - Improved job command to show timestamps in RFC 3339 (1994-11-06T08:49:37Z) + format. + 6.04 2017-03-18 - Added -f option to worker command. - Removed -r option from job command, so you have to write --remove from now diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Minion-6.04/META.json new/Minion-6.05/META.json --- old/Minion-6.04/META.json 2017-03-20 09:56:59.000000000 +0100 +++ new/Minion-6.05/META.json 2017-04-06 13:54:38.000000000 +0200 @@ -33,7 +33,7 @@ }, "runtime" : { "requires" : { - "Mojolicious" : "6.0", + "Mojolicious" : "7.29", "perl" : "5.010001" } } @@ -54,6 +54,6 @@ }, "x_IRC" : "irc://irc.perl.org/#mojo" }, - "version" : "6.04", + "version" : "6.05", "x_serialization_backend" : "JSON::PP version 2.27400" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Minion-6.04/META.yml new/Minion-6.05/META.yml --- old/Minion-6.04/META.yml 2017-03-20 09:56:59.000000000 +0100 +++ new/Minion-6.05/META.yml 2017-04-06 13:54:38.000000000 +0200 @@ -19,7 +19,7 @@ - inc - t requires: - Mojolicious: '6.0' + Mojolicious: '7.29' perl: '5.010001' resources: IRC: irc://irc.perl.org/#mojo @@ -27,5 +27,5 @@ homepage: http://mojolicious.org license: http://www.opensource.org/licenses/artistic-license-2.0 repository: https://github.com/kraih/minion.git -version: '6.04' +version: '6.05' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Minion-6.04/Makefile.PL new/Minion-6.05/Makefile.PL --- old/Minion-6.04/Makefile.PL 2016-06-24 08:49:50.000000000 +0200 +++ new/Minion-6.05/Makefile.PL 2017-04-03 19:47:30.000000000 +0200 @@ -28,6 +28,6 @@ x_IRC => 'irc://irc.perl.org/#mojo' }, }, - PREREQ_PM => {Mojolicious => '6.0'}, + PREREQ_PM => {Mojolicious => '7.29'}, test => {TESTS => 't/*.t t/*/*.t'} ); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Minion-6.04/README.md new/Minion-6.05/README.md --- old/Minion-6.04/README.md 2017-02-14 20:38:10.000000000 +0100 +++ new/Minion-6.05/README.md 2017-04-03 20:12:28.000000000 +0200 @@ -51,4 +51,4 @@ ## Want to know more? Take a look at our excellent - [documentation](http://mojolicious.org/perldoc/Minion>)! + [documentation](http://mojolicious.org/perldoc/Minion)! diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Minion-6.04/lib/Minion/Backend/Pg.pm new/Minion-6.05/lib/Minion/Backend/Pg.pm --- old/Minion-6.04/lib/Minion/Backend/Pg.pm 2017-03-16 16:44:20.000000000 +0100 +++ new/Minion-6.05/lib/Minion/Backend/Pg.pm 2017-04-04 04:24:46.000000000 +0200 @@ -104,13 +104,14 @@ } sub register_worker { - my ($self, $id) = @_; + my ($self, $id, $options) = (shift, shift, shift || {}); return $self->pg->db->query( - "insert into minion_workers (id, host, pid) - values (coalesce(?, nextval('minion_workers_id_seq')), ?, ?) - on conflict(id) do update set notified = now() - returning id", $id, $self->{host} //= hostname, $$ + q{insert into minion_workers (id, host, pid, status) + values (coalesce($1, nextval('minion_workers_id_seq')), $2, $3, $4) + on conflict(id) do update set notified = now(), status = $4 + returning id}, $id, $self->{host} //= hostname, $$, + {json => $options->{status} // {}} )->hash->{id}; } @@ -174,7 +175,6 @@ priority = coalesce(?, priority), queue = coalesce(?, queue), retried = now(), retries = retries + 1, state = 'inactive' where id = ? and retries = ? - and state in ('inactive', 'failed', 'finished') returning 1", $options->{delay} // 0, @$options{qw(priority queue)}, $id, $retries )->rows; @@ -212,10 +212,10 @@ "select id, extract(epoch from notified) as notified, array( select id from minion_jobs where state = 'active' and worker = minion_workers.id - ) as jobs, host, pid, extract(epoch from started) as started + ) as jobs, host, pid, status, extract(epoch from started) as started from minion_workers where id = ?", shift - )->hash; + )->expand->hash; } sub _try { @@ -585,9 +585,23 @@ my $worker_id = $backend->register_worker; my $worker_id = $backend->register_worker($worker_id); + my $worker_id = $backend->register_worker( + $worker_id, {status => {queues => ['default', 'important']}}); Register worker or send heartbeat to show that this worker is still alive. +These options are currently available: + +=over 2 + +=item status + + status => {queues => ['default', 'important']} + +Hash reference with whatever status information the worker would like to share. + +=back + =head2 remove_job my $bool = $backend->remove_job($job_id); @@ -611,8 +625,8 @@ my $bool = $backend->retry_job($job_id, $retries); my $bool = $backend->retry_job($job_id, $retries, {delay => 10}); -Transition from C<failed> or C<finished> state back to C<inactive>, already -C<inactive> jobs may also be retried to change options. +Transition job back to C<inactive> state, already C<inactive> jobs may also be +retried to change options. These options are currently available: @@ -750,6 +764,12 @@ Epoch time worker was started. +=item status + + status => {queues => ['default', 'important']} + +Hash reference with whatever status information the worker would like to share. + =back =head1 SEE ALSO @@ -852,5 +872,6 @@ -- 13 up create index on minion_jobs using gin (parents); --- 14 up -drop index minion_jobs_parents_idx; +-- 15 up +alter table minion_workers add column status jsonb + check(jsonb_typeof(status) = 'object') default '{}'; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Minion-6.04/lib/Minion/Backend.pm new/Minion-6.05/lib/Minion/Backend.pm --- old/Minion-6.04/lib/Minion/Backend.pm 2017-02-14 20:37:29.000000000 +0100 +++ new/Minion-6.05/lib/Minion/Backend.pm 2017-04-03 15:01:11.000000000 +0200 @@ -373,10 +373,24 @@ my $worker_id = $backend->register_worker; my $worker_id = $backend->register_worker($worker_id); + my $worker_id = $backend->register_worker( + $worker_id, {status => {queues => ['default', 'important']}}); Register worker or send heartbeat to show that this worker is still alive. Meant to be overloaded in a subclass. +These options are currently available: + +=over 2 + +=item status + + status => {queues => ['default', 'important']} + +Hash reference with whatever status information the worker would like to share. + +=back + =head2 remove_job my $bool = $backend->remove_job($job_id); @@ -402,9 +416,8 @@ my $bool = $backend->retry_job($job_id, $retries); my $bool = $backend->retry_job($job_id, $retries, {delay => 10}); -Transition from C<failed> or C<finished> state back to C<inactive>, already -C<inactive> jobs may also be retried to change options. Meant to be overloaded -in a subclass. +Transition job back to C<inactive> state, already C<inactive> jobs may also be +retried to change options. Meant to be overloaded in a subclass. These options are currently available: @@ -536,6 +549,12 @@ Epoch time worker was started. +=item status + + status => {queues => ['default', 'important']} + +Hash reference with whatever status information the worker would like to share. + =back =head1 SEE ALSO diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Minion-6.04/lib/Minion/Command/minion/job.pm new/Minion-6.05/lib/Minion/Command/minion/job.pm --- old/Minion-6.04/lib/Minion/Command/minion/job.pm 2017-03-18 16:01:43.000000000 +0100 +++ new/Minion-6.05/lib/Minion/Command/minion/job.pm 2017-04-04 01:06:20.000000000 +0200 @@ -1,9 +1,9 @@ package Minion::Command::minion::job; use Mojo::Base 'Mojolicious::Command'; -use Getopt::Long qw(GetOptionsFromArray :config no_auto_abbrev no_ignore_case); +use Mojo::Date; use Mojo::JSON 'decode_json'; -use Mojo::Util qw(dumper tablify); +use Mojo::Util qw(dumper getopt tablify); has description => 'Manage Minion jobs'; has usage => sub { shift->extract_usage }; @@ -12,7 +12,7 @@ my ($self, @args) = @_; my ($args, $options) = ([], {}); - GetOptionsFromArray \@args, + getopt \@args, 'A|attempts=i' => \$options->{attempts}, 'a|args=s' => sub { $args = decode_json($_[1]) }, 'b|broadcast=s' => (\my $command), @@ -54,7 +54,14 @@ return $job->retry($options) || die "Job is active.\n" if $retry; # Job info - print dumper $job->info; + print dumper _datetime($job->info); +} + +sub _datetime { + my $hash = shift; + $hash->{$_} and $hash->{$_} = Mojo::Date->new($hash->{$_})->to_datetime + for qw(created delayed finished notified retried started); + return $hash; } sub _list_jobs { @@ -73,7 +80,7 @@ sub _worker { die "Worker does not exist.\n" unless my $worker = shift->app->minion->backend->worker_info(@_); - print dumper $worker; + print dumper _datetime($worker); } 1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Minion-6.04/lib/Minion/Command/minion/worker.pm new/Minion-6.05/lib/Minion/Command/minion/worker.pm --- old/Minion-6.04/lib/Minion/Command/minion/worker.pm 2017-03-18 16:16:39.000000000 +0100 +++ new/Minion-6.05/lib/Minion/Command/minion/worker.pm 2017-04-04 22:22:04.000000000 +0200 @@ -1,8 +1,7 @@ package Minion::Command::minion::worker; use Mojo::Base 'Mojolicious::Command'; -use Getopt::Long qw(GetOptionsFromArray :config no_auto_abbrev no_ignore_case); -use Mojo::Util 'steady_time'; +use Mojo::Util qw(getopt steady_time); has description => 'Start Minion worker'; has usage => sub { shift->extract_usage }; @@ -10,15 +9,21 @@ sub run { my ($self, @args) = @_; - GetOptionsFromArray \@args, - 'C|command-interval=i' => \($self->{commands} = 10), + my $app = $self->app; + my $worker = $self->{worker} = $app->minion->worker; + my $status = $worker->status; + $status->{performed} //= 0; + + getopt \@args, + 'C|command-interval=i' => \($status->{command_interval} //= 10), 'f|fast-start' => \my $fast, - 'I|heartbeat-interval=i' => \($self->{heartbeat} = 60), - 'j|jobs=i' => \($self->{max} = 4), - 'q|queue=s' => \my @queues, - 'R|repair-interval=i' => \($self->{repair} = 21600); - $self->{queues} = @queues ? \@queues : ['default']; - $self->_next_repair if $fast; + 'I|heartbeat-interval=i' => \($status->{heartbeat_interval} //= 300), + 'j|jobs=i' => \($status->{jobs} //= 4), + 'q|queue=s' => ($status->{queues} //= []), + 'R|repair-interval=i' => \($status->{repair_interval} //= 21600); + @{$status->{queues}} = ('default') unless @{$status->{queues}}; + $status->{repair_interval} -= int rand $status->{repair_interval} / 2; + $self->{last_repair} = $fast ? steady_time : 0; local $SIG{CHLD} = 'DEFAULT'; local $SIG{INT} = local $SIG{TERM} = sub { $self->{finished}++ }; @@ -26,10 +31,8 @@ = sub { ++$self->{finished} and kill 'KILL', keys %{$self->{jobs}} }; # Remote control commands need to validate arguments carefully - my $app = $self->app; - my $worker = $self->{worker} = $app->minion->worker; $worker->add_command( - jobs => sub { $self->{max} = $_[1] if ($_[1] // '') =~ /^\d+$/ }); + jobs => sub { $status->{jobs} = $_[1] if ($_[1] // '') =~ /^\d+$/ }); $worker->add_command( stop => sub { $self->{jobs}{$_[1]}->stop if $self->{jobs}{$_[1] // ''} }); @@ -40,41 +43,39 @@ $worker->unregister; } -sub _next_repair { - my $self = shift; - $self->{check} - = steady_time + ($self->{repair} - int rand $self->{repair} / 2); -} - sub _work { my $self = shift; # Send heartbeats in regular intervals my $worker = $self->{worker}; - $worker->register and $self->{lr} = steady_time + $self->{heartbeat} - if ($self->{lr} || 0) < steady_time; + my $status = $worker->status; + $self->{last_heartbeat} ||= 0; + $worker->register and $self->{last_heartbeat} = steady_time + if ($self->{last_heartbeat} + $status->{heartbeat_interval}) < steady_time; # Process worker remote control commands in regular intervals - $worker->process_commands and $self->{lp} = steady_time + $self->{commands} - if ($self->{lp} || 0) < steady_time; + $self->{last_command} ||= 0; + $worker->process_commands and $self->{last_command} = steady_time + if ($self->{last_command} + $status->{command_interval}) < steady_time; # Repair in regular intervals (randomize to avoid congestion) - if (($self->{check} || 0) < steady_time) { + if (($self->{last_repair} + $status->{repair_interval}) < steady_time) { my $app = $self->app; $app->log->debug('Checking worker registry and job queue'); $app->minion->repair; - $self->_next_repair; + $self->{last_repair} = steady_time; } # Check if jobs are finished my $jobs = $self->{jobs} ||= {}; - $jobs->{$_}->is_finished and delete $jobs->{$_} for keys %$jobs; + $jobs->{$_}->is_finished and ++$status->{performed} and delete $jobs->{$_} + for keys %$jobs; # Wait if job limit has been reached or worker is stopping - if (($self->{max} <= keys %$jobs) || $self->{finished}) { sleep 1 } + if (($status->{jobs} <= keys %$jobs) || $self->{finished}) { sleep 1 } # Try to get more jobs - elsif (my $job = $worker->dequeue(5 => {queues => $self->{queues}})) { + elsif (my $job = $worker->dequeue(5 => {queues => $status->{queues}})) { $jobs->{my $id = $job->id} = $job->start; my ($pid, $task) = ($job->pid, $job->task); $self->app->log->debug( @@ -108,7 +109,7 @@ --home <path> Path to home directory of your application, defaults to the value of MOJO_HOME or auto-detection - -I, --heartbeat-interval <seconds> Heartbeat interval, defaults to 60 + -I, --heartbeat-interval <seconds> Heartbeat interval, defaults to 300 -j, --jobs <number> Maximum number of jobs to perform parallel in forked worker processes, defaults to 4 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Minion-6.04/lib/Minion/Job.pm new/Minion-6.05/lib/Minion/Job.pm --- old/Minion-6.04/lib/Minion/Job.pm 2017-02-14 20:37:50.000000000 +0100 +++ new/Minion-6.05/lib/Minion/Job.pm 2017-04-02 19:05:59.000000000 +0200 @@ -364,8 +364,8 @@ my $bool = $job->retry; my $bool = $job->retry({delay => 10}); -Transition from C<failed> or C<finished> state back to C<inactive>, already -C<inactive> jobs may also be retried to change options. +Transition job back to C<inactive> state, already C<inactive> jobs may also be +retried to change options. These options are currently available: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Minion-6.04/lib/Minion/Worker.pm new/Minion-6.05/lib/Minion/Worker.pm --- old/Minion-6.04/lib/Minion/Worker.pm 2016-09-17 10:55:06.000000000 +0200 +++ new/Minion-6.05/lib/Minion/Worker.pm 2017-04-04 04:24:51.000000000 +0200 @@ -1,7 +1,7 @@ package Minion::Worker; use Mojo::Base 'Mojo::EventEmitter'; -has commands => sub { {} }; +has [qw(commands status)] => sub { {} }; has [qw(id minion)]; sub add_command { $_[0]->commands->{$_[1]} = $_[2] and return $_[0] } @@ -38,7 +38,11 @@ return $self; } -sub register { $_[0]->id($_[0]->minion->backend->register_worker($_[0]->id)) } +sub register { + my $self = shift; + my $status = {status => $self->status}; + return $self->id($self->minion->backend->register_worker($self->id, $status)); +} sub unregister { my $self = shift; @@ -109,6 +113,13 @@ L<Minion> object this worker belongs to. +=head2 status + + my $status = $worker->status; + $worker = $worker->status({queues => ['default', 'important']); + +Status information to share every time L</"register"> is called. + =head1 METHODS L<Minion::Worker> inherits all methods from L<Mojo::EventEmitter> and @@ -189,6 +200,12 @@ Epoch time worker was started. +=item status + + status => {queues => ['default', 'important']} + +Hash reference with whatever status information the worker would like to share. + =back =head2 process_commands diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Minion-6.04/lib/Minion.pm new/Minion-6.05/lib/Minion.pm --- old/Minion-6.04/lib/Minion.pm 2017-03-15 00:25:05.000000000 +0100 +++ new/Minion-6.05/lib/Minion.pm 2017-04-04 01:06:20.000000000 +0200 @@ -16,7 +16,7 @@ has remove_after => 172800; has tasks => sub { {} }; -our $VERSION = '6.04'; +our $VERSION = '6.05'; sub add_task { ($_[0]->tasks->{$_[1]} = $_[2]) and return $_[0] } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Minion-6.04/t/pg.t new/Minion-6.05/t/pg.t --- old/Minion-6.04/t/pg.t 2017-03-14 18:03:45.000000000 +0100 +++ new/Minion-6.05/t/pg.t 2017-04-04 04:24:42.000000000 +0200 @@ -24,11 +24,11 @@ isa_ok $worker->minion->app, 'Mojolicious', 'has default application'; # Migrate up and down -is $minion->backend->pg->migrations->active, 14, 'active version is 14'; +is $minion->backend->pg->migrations->active, 15, 'active version is 15'; is $minion->backend->pg->migrations->migrate(0)->active, 0, 'active version is 0'; -is $minion->backend->pg->migrations->migrate->active, 14, - 'active version is 14'; +is $minion->backend->pg->migrations->migrate->active, 15, + 'active version is 15'; # Register and unregister $worker->register; @@ -107,8 +107,8 @@ ok !$minion->job($id3), 'job has been cleaned up'; # List workers -$worker = $minion->worker->register; -$worker2 = $minion->worker->register; +$worker = $minion->worker->register; +$worker2 = $minion->worker->status({whatever => 'works!'})->register; my $batch = $minion->backend->list_workers(0, 10); ok $batch->[0]{id}, 'has id'; is $batch->[0]{host}, $host, 'right host'; @@ -119,7 +119,11 @@ ok !$batch->[2], 'no more results'; $batch = $minion->backend->list_workers(0, 1); is $batch->[0]{id}, $worker2->id, 'right id'; +is_deeply $batch->[0]{status}, {whatever => 'works!'}, 'right status'; ok !$batch->[1], 'no more results'; +$worker2->status({whatever => 'works too!'})->register; +$batch = $minion->backend->list_workers(0, 1); +is_deeply $batch->[0]{status}, {whatever => 'works too!'}, 'right status'; $batch = $minion->backend->list_workers(1, 1); is $batch->[0]{id}, $worker->id, 'right id'; ok !$batch->[1], 'no more results'; @@ -291,17 +295,15 @@ is $job->info->{retries}, 1, 'job has been retried once'; $job = $worker->dequeue(0); is $job->retries, 1, 'job has been retried once'; -ok !$job->retry, 'job not retried'; -is $job->id, $id, 'right id'; -ok !$job->remove, 'job has not been removed'; -ok $job->fail, 'job failed'; ok $job->retry, 'job retried'; +is $job->id, $id, 'right id'; is $job->info->{retries}, 2, 'job has been retried twice'; $job = $worker->dequeue(0); is $job->info->{state}, 'active', 'right state'; ok $job->finish, 'job finished'; ok $job->remove, 'job has been removed'; -is $job->info, undef, 'no information'; +ok !$job->retry, 'job not retried'; +is $job->info, undef, 'no information'; $id = $minion->enqueue(add => [6, 5]); $job = $minion->job($id); is $job->info->{state}, 'inactive', 'right state';
