inst-jobs 3.1.7 → 3.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/delayed/backend/base.rb +3 -0
- data/lib/delayed/performable_method.rb +17 -13
- data/lib/delayed/settings.rb +2 -0
- data/lib/delayed/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: 4ecc79cbf0af3c0205febacfb4124bf1b86183132fd28f1330b0fb9c097efe62
|
4
|
+
data.tar.gz: 31f7cb19c7ecc6b71833dcc31b998642fec44e06d1bfbaefc2ed868fe331688a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d76db82af500258ac736d6b3819fffcccc0afe81a4c44cf01c540252695f3a3b2d120c00576f4ee02459e0808ddcb1d19c25ddb16c41945fc103718fa8011e3
|
7
|
+
data.tar.gz: 6f6efc00e1a707f5e984455db881281f56eac2b06fd17ee75a5a574c883fcdcb7c99b1483d3d3cadb6d501d6ee4c98b031b997e285bdf598bbc257cf6fb83364
|
data/lib/delayed/backend/base.rb
CHANGED
@@ -62,6 +62,9 @@ module Delayed
|
|
62
62
|
kwargs[:singleton] = singleton
|
63
63
|
|
64
64
|
raise ArgumentError, "Only one of strand or n_strand can be used" if strand && n_strand
|
65
|
+
if (strand || n_strand) && run_at && run_at > Job.db_time_now + Settings.stranded_run_at_grace_period
|
66
|
+
raise ArgumentError, "Do not use run_at with strand; you may inadvertently clog the strand"
|
67
|
+
end
|
65
68
|
|
66
69
|
# If two parameters are given to n_strand, the first param is used
|
67
70
|
# as the strand name for looking up the Setting, while the second
|
@@ -1,7 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Delayed
|
4
|
-
PerformableMethod = Struct.new(:object,
|
4
|
+
PerformableMethod = Struct.new(:object,
|
5
|
+
:method, # rubocop:disable Lint/StructNewOverride
|
6
|
+
:args,
|
7
|
+
:kwargs,
|
8
|
+
:fail_cb,
|
9
|
+
:permanent_fail_cb,
|
10
|
+
:sender,
|
11
|
+
:sender_is_object,
|
12
|
+
:sender_is_class) do
|
5
13
|
def initialize(object, method, args: [], kwargs: {}, on_failure: nil, on_permanent_failure: nil, sender: nil)
|
6
14
|
raise NoMethodError, "undefined method `#{method}' for #{object.inspect}" unless object.respond_to?(method, true)
|
7
15
|
|
@@ -11,13 +19,8 @@ module Delayed
|
|
11
19
|
self.method = method.to_sym
|
12
20
|
self.fail_cb = on_failure
|
13
21
|
self.permanent_fail_cb = on_permanent_failure
|
14
|
-
self.
|
15
|
-
|
16
|
-
YAML.load(YAML.dump(sender))
|
17
|
-
rescue
|
18
|
-
# if for some reason you can't dump the sender, just drop it
|
19
|
-
self.sender = nil
|
20
|
-
end
|
22
|
+
self.sender_is_object = sender.equal?(object)
|
23
|
+
self.sender_is_class = sender.is_a?(object.class)
|
21
24
|
end
|
22
25
|
|
23
26
|
def display_name
|
@@ -32,14 +35,15 @@ module Delayed
|
|
32
35
|
def perform
|
33
36
|
kwargs = self.kwargs || {}
|
34
37
|
|
35
|
-
|
36
|
-
|
38
|
+
# back-compat for jobs queued before we assigned these in initialize
|
39
|
+
self.sender_is_object = sender == object if sender_is_object.nil?
|
40
|
+
self.sender_is_class = sender.is_a?(object.class) if sender_is_class.nil?
|
37
41
|
|
38
|
-
if
|
42
|
+
if sender_is_object || (sender_is_class && object.protected_methods.include?(method))
|
39
43
|
if kwargs.empty?
|
40
|
-
object.
|
44
|
+
object.__send__(method, *args)
|
41
45
|
else
|
42
|
-
object.
|
46
|
+
object.__send__(method, *args, **kwargs)
|
43
47
|
end
|
44
48
|
elsif kwargs.empty?
|
45
49
|
object.public_send(method, *args)
|
data/lib/delayed/settings.rb
CHANGED
@@ -26,6 +26,7 @@ module Delayed
|
|
26
26
|
:sleep_delay,
|
27
27
|
:sleep_delay_stagger,
|
28
28
|
:slow_exit_timeout,
|
29
|
+
:stranded_run_at_grace_period,
|
29
30
|
:worker_health_check_type,
|
30
31
|
:worker_health_check_config,
|
31
32
|
:worker_procname_prefix
|
@@ -132,6 +133,7 @@ module Delayed
|
|
132
133
|
self.fetch_batch_size = 5
|
133
134
|
self.select_random_from_batch = false
|
134
135
|
self.silence_periodic_log = false
|
136
|
+
self.stranded_run_at_grace_period = 10
|
135
137
|
|
136
138
|
self.num_strands = ->(_strand_name) {}
|
137
139
|
self.default_job_options = -> { {} }
|
data/lib/delayed/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inst-jobs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Cutrer
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-
|
13
|
+
date: 2023-04-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|