sidekiq-amigo 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c51def3cb58812e0889c0768708747aefd3956495692ffcbb6521a1d24c6d0b0
4
- data.tar.gz: 5081debc483ce040e8c6f3a26cfacdd85094c5e70895b390f23f58f795663da3
3
+ metadata.gz: 14e6bc3120144858128f363dc8e949a7426934cafd845a3437119e02a93787c6
4
+ data.tar.gz: e93ebb50c72196c2485fd5e2f69b22bb6c1eb9765520d03cbfb7ce45d7dffaf1
5
5
  SHA512:
6
- metadata.gz: b126004a168ea18f4842bd34268fc3edb263d21de40731d178e9bd4a5db64bf403da0953b6083ea0e5c5e8d32bc9aa4faf0e66e54f0f166a077780d6573565f6
7
- data.tar.gz: 4a710ac1029e607ed60b1f448e4c443d287bcb599252801a70a17a9478e0f5c80b373f610a14034be1d2d3c98541512e64ab2f8b2bc85869b70fbc009308007d
6
+ metadata.gz: 0dcb1d84ea09a01170fb2daf31f4671e49105edafc687a7d6521b673a18f02891115207cf71d3345a2a6fe4fda7c9cf9165929a766bba76f5dc41e61957fff0e
7
+ data.tar.gz: 1c19c16aaa290dbc372bc8baf0cb328aef784439361d353a06179ae8e2b7b20033970ef3c82f3865ef25cd02110e7aca51e567613feb62ef341c0b119d00b0e1
@@ -22,11 +22,12 @@ module Amigo
22
22
  end
23
23
 
24
24
  def perform(*args)
25
- if args.empty?
25
+ splay = self.class.splay_duration
26
+ if splay.nil? || args == [true]
27
+ self._perform
28
+ elsif args.empty?
26
29
  jitter = rand(0..self.class.splay_duration.to_i)
27
30
  self.class.perform_in(jitter, true)
28
- elsif args == [true]
29
- self._perform
30
31
  else
31
32
  raise "ScheduledJob#perform must be called with no arguments, or [true]"
32
33
  end
@@ -62,6 +63,16 @@ module Amigo
62
63
  self.cron_expr = expr
63
64
  end
64
65
 
66
+ # When the cron job is run, it is re-enqueued
67
+ # again with a random offset. This splay prevents
68
+ # the 'thundering herd' problem, where, say, may jobs
69
+ # are meant to happen at minute 0. Instead, jobs are offset.
70
+ #
71
+ # Use +nil+ to turn off this behavior and get more precise execution.
72
+ # This is mostly useful for jobs that must run very often.
73
+ #
74
+ # +duration+ must respond to +to_i+.
75
+ # @param duration [Integer,#to_i]
65
76
  def splay(duration)
66
77
  self.splay_duration = duration
67
78
  end
data/lib/amigo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Amigo
4
- VERSION = "1.6.0"
4
+ VERSION = "1.6.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-amigo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lithic Technology
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-02 00:00:00.000000000 Z
11
+ date: 2023-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq