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 +4 -4
- data/lib/amigo/scheduled_job.rb +14 -3
- data/lib/amigo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14e6bc3120144858128f363dc8e949a7426934cafd845a3437119e02a93787c6
|
4
|
+
data.tar.gz: e93ebb50c72196c2485fd5e2f69b22bb6c1eb9765520d03cbfb7ce45d7dffaf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dcb1d84ea09a01170fb2daf31f4671e49105edafc687a7d6521b673a18f02891115207cf71d3345a2a6fe4fda7c9cf9165929a766bba76f5dc41e61957fff0e
|
7
|
+
data.tar.gz: 1c19c16aaa290dbc372bc8baf0cb328aef784439361d353a06179ae8e2b7b20033970ef3c82f3865ef25cd02110e7aca51e567613feb62ef341c0b119d00b0e1
|
data/lib/amigo/scheduled_job.rb
CHANGED
@@ -22,11 +22,12 @@ module Amigo
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def perform(*args)
|
25
|
-
|
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
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.
|
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-
|
11
|
+
date: 2023-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|