Hello community,

here is the log from the commit of package perl-Minion for openSUSE:Factory 
checked in at 2017-09-23 21:36:05
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Minion (Old)
 and      /work/SRC/openSUSE:Factory/.perl-Minion.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "perl-Minion"

Sat Sep 23 21:36:05 2017 rev:30 rq:528229 version:7.06

Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-Minion/perl-Minion.changes  2017-08-10 
14:13:19.458137299 +0200
+++ /work/SRC/openSUSE:Factory/.perl-Minion.new/perl-Minion.changes     
2017-09-23 21:36:12.413612068 +0200
@@ -1,0 +2,9 @@
+Fri Sep 22 05:42:22 UTC 2017 - [email protected]
+
+- updated to 7.06
+   see /usr/share/doc/packages/perl-Minion/Changes
+
+  7.06  2017-09-21
+    - Added guard method to Minion.
+
+-------------------------------------------------------------------

Old:
----
  Minion-7.05.tar.gz

New:
----
  Minion-7.06.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ perl-Minion.spec ++++++
--- /var/tmp/diff_new_pack.blW97x/_old  2017-09-23 21:36:13.605444455 +0200
+++ /var/tmp/diff_new_pack.blW97x/_new  2017-09-23 21:36:13.613443331 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           perl-Minion
-Version:        7.05
+Version:        7.06
 Release:        0
 %define cpan_name Minion
 Summary:        Job queue

++++++ Minion-7.05.tar.gz -> Minion-7.06.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Minion-7.05/Changes new/Minion-7.06/Changes
--- old/Minion-7.05/Changes     2017-08-07 17:44:43.000000000 +0200
+++ new/Minion-7.06/Changes     2017-09-21 11:19:39.000000000 +0200
@@ -1,4 +1,7 @@
 
+7.06  2017-09-21
+  - Added guard method to Minion.
+
 7.05  2017-08-07
   - Improved foreground method in Minion to rethrow job exceptions.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Minion-7.05/META.json new/Minion-7.06/META.json
--- old/Minion-7.05/META.json   2017-08-07 21:47:04.000000000 +0200
+++ new/Minion-7.06/META.json   2017-09-21 19:46:25.000000000 +0200
@@ -54,6 +54,6 @@
       },
       "x_IRC" : "irc://irc.perl.org/#mojo"
    },
-   "version" : "7.05",
+   "version" : "7.06",
    "x_serialization_backend" : "JSON::PP version 2.94"
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Minion-7.05/META.yml new/Minion-7.06/META.yml
--- old/Minion-7.05/META.yml    2017-08-07 21:47:04.000000000 +0200
+++ new/Minion-7.06/META.yml    2017-09-21 19:46:25.000000000 +0200
@@ -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: '7.05'
+version: '7.06'
 x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Minion-7.05/lib/Minion.pm 
new/Minion-7.06/lib/Minion.pm
--- old/Minion-7.05/lib/Minion.pm       2017-08-07 17:46:30.000000000 +0200
+++ new/Minion-7.06/lib/Minion.pm       2017-09-21 11:19:16.000000000 +0200
@@ -16,7 +16,7 @@
 has remove_after  => 172800;
 has tasks         => sub { {} };
 
-our $VERSION = '7.05';
+our $VERSION = '7.06';
 
 sub add_task { ($_[0]->tasks->{$_[1]} = $_[2]) and return $_[0] }
 
@@ -43,6 +43,12 @@
   return defined $err ? die $err : !!$job;
 }
 
+sub guard {
+  my ($self, $lock) = (shift, shift);
+  return undef unless $self->lock($lock, @_);
+  return Minion::_Guard->new(minion => $self, lock => $lock);
+}
+
 sub job {
   my ($self, $id) = @_;
 
@@ -103,6 +109,11 @@
   return $self;
 }
 
+package Minion::_Guard;
+use Mojo::Base -base;
+
+sub DESTROY { $_[0]{minion}->unlock($_[0]{lock}) }
+
 1;
 
 =encoding utf8
@@ -417,6 +428,31 @@
 Retry job in C<minion_foreground> queue, then perform it right away with a
 temporary worker in this process, very useful for debugging.
 
+=head2 guard
+
+  my $guard = $minion->guard('foo', 3600);
+  my $guard = $minion->guard('foo', 3600, {limit => 20});
+
+Same as L</"lock">, but returns a scope guard object that automatically 
releases
+the lock as soon as the object is destroyed, or C<undef> if aquiring the lock
+failed.
+
+  # Only one job should run at a time (unique job)
+  $minion->add_task(do_unique_stuff => sub {
+    my ($job, @args) = @_;
+    return $job->finish('Previous job is still active')
+      unless my $guard = $minion->guard('fragile_backend_service', 7200);
+    ...
+  });
+
+  # Only five jobs should run at a time and we try again later if necessary
+  $minion->add_task(do_concurrent_stuff => sub {
+    my ($job, @args) = @_;
+    return $job->retry({delay => 30})
+      unless my $guard = $minion->guard('some_web_service', 60, {limit => 5});
+    ...
+  });
+
 =head2 job
 
   my $job = $minion->job($id);
@@ -440,7 +476,9 @@
 
 Try to acquire a named lock that will expire automatically after the given
 amount of time in seconds. You can release the lock manually with L</"unlock">
-to limit concurrency, or let it expire for rate limiting.
+to limit concurrency, or let it expire for rate limiting. For convenience you
+can also use L</"guard"> to release the lock automatically, even if the job
+failed.
 
   # Only one job should run at a time (unique job)
   $minion->add_task(do_unique_stuff => sub {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Minion-7.05/t/pg.t new/Minion-7.06/t/pg.t
--- old/Minion-7.05/t/pg.t      2017-08-07 20:22:00.000000000 +0200
+++ new/Minion-7.06/t/pg.t      2017-09-21 11:15:52.000000000 +0200
@@ -160,6 +160,16 @@
 ok $minion->unlock('baz'), 'unlocked';
 ok !$minion->unlock('baz'), 'not unlocked again';
 
+# Lock with guard
+ok my $guard = $minion->guard('foo', 3600, {limit => 1}), 'locked';
+ok !$minion->guard('foo', 3600, {limit => 1}), 'not locked again';
+undef $guard;
+ok $guard = $minion->guard('foo', 3600), 'locked';
+ok !$minion->guard('foo', 3600), 'not locked again';
+undef $guard;
+ok $minion->guard('foo', 3600, {limit => 1}), 'locked again';
+ok $minion->guard('foo', 3600, {limit => 1}), 'locked again';
+
 # Reset
 $minion->reset->repair;
 ok !$minion->backend->pg->db->query(


Reply via email to