switchman-inst-jobs 1.3.5 → 1.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/switchman_inst_jobs/delayed/worker/health_check.rb +1 -3
- data/lib/switchman_inst_jobs/new_relic.rb +1 -3
- data/lib/switchman_inst_jobs/switchman/database_server.rb +6 -1
- data/lib/switchman_inst_jobs/switchman/shard.rb +25 -12
- data/lib/switchman_inst_jobs/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: e39492734082a2e3a5f6a7056fcf6bef4ebda5952cbd9188de8fc8ae0e938630
|
4
|
+
data.tar.gz: f6dfdaf0c045612ac8af1cba019e01b9cd9a5ad75164f8dacd03fd030d0884a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 852061f2038fc91038289fe3fa2ce9a9b69cdc54e6aaa0aba403fed22ba1d9bd9b62da1215805bb6b598a3d5f9fa43b48748dde828c6ce60c62587952fb7d024
|
7
|
+
data.tar.gz: 40d8fa1ff7e15c54e4ad5c3ce967759d707c7eb8be9da70894768ae3d46aa93d4133003bdf95aa563c1a6baf9dfdf46ccdf8e642c9b6f7592ec5058775c5e87d
|
@@ -21,9 +21,7 @@ module SwitchmanInstJobs
|
|
21
21
|
def reschedule_abandoned_jobs(call_super: false)
|
22
22
|
shards = ::Switchman::Shard.delayed_jobs_shards
|
23
23
|
call_super = true if shards.length == 1
|
24
|
-
if call_super
|
25
|
-
return munge_service_name(::Switchman::Shard.current(:delayed_jobs)) { super() }
|
26
|
-
end
|
24
|
+
return munge_service_name(::Switchman::Shard.current(:delayed_jobs)) { super() } if call_super
|
27
25
|
|
28
26
|
::Switchman::Shard.with_each_shard(shards, [:delayed_jobs], exception: :ignore) do
|
29
27
|
singleton = <<~SINGLETON
|
@@ -2,9 +2,7 @@ module SwitchmanInstJobs
|
|
2
2
|
module NewRelic
|
3
3
|
module FixNewRelicDelayedJobs
|
4
4
|
module NewRelicJobInvoker
|
5
|
-
if defined?(::NewRelic)
|
6
|
-
include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
7
|
-
end
|
5
|
+
include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation if defined?(::NewRelic)
|
8
6
|
|
9
7
|
def invoke_job(*args, &block)
|
10
8
|
options = {
|
@@ -8,7 +8,12 @@ module SwitchmanInstJobs
|
|
8
8
|
::Switchman::Shard.lookup(config[:delayed_jobs_shard])
|
9
9
|
# have to avoid recursion for the default shard asking for the default
|
10
10
|
# shard's delayed_jobs_shard
|
11
|
-
|
11
|
+
if shard&.default?
|
12
|
+
# first look for any shard that behaves like a jobs shard
|
13
|
+
dj_shard ||= ::Switchman::Shard.delayed_jobs_shards.first
|
14
|
+
# we're really truly out of options, use the default shard itself
|
15
|
+
dj_shard ||= shard
|
16
|
+
end
|
12
17
|
dj_shard ||= SwitchmanInstJobs.delayed_jobs_shard_fallback&.call(self, shard)
|
13
18
|
dj_shard || ::Switchman::Shard.default.delayed_jobs_shard
|
14
19
|
end
|
@@ -18,6 +18,11 @@ module SwitchmanInstJobs
|
|
18
18
|
end
|
19
19
|
|
20
20
|
module ClassMethods
|
21
|
+
def clear_cache
|
22
|
+
super
|
23
|
+
remove_instance_variable(:@delayed_jobs_shards) if instance_variable_defined?(:@delayed_jobs_shards)
|
24
|
+
end
|
25
|
+
|
21
26
|
def current(category = :primary)
|
22
27
|
if category == :delayed_jobs
|
23
28
|
active_shards[category] || super(:primary).delayed_jobs_shard
|
@@ -53,19 +58,27 @@ module SwitchmanInstJobs
|
|
53
58
|
end
|
54
59
|
|
55
60
|
def delayed_jobs_shards
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
.
|
64
|
-
.
|
65
|
-
|
66
|
-
|
67
|
-
|
61
|
+
unless instance_variable_defined?(:@delayed_jobs_shards)
|
62
|
+
# re-entrancy protection
|
63
|
+
@delayed_jobs_shards = []
|
64
|
+
@delayed_jobs_shards = begin
|
65
|
+
db_dj_shards = ::Switchman::DatabaseServer.all.map do |db|
|
66
|
+
next db.shards.to_a if db.config[:delayed_jobs_shard] == 'self'
|
67
|
+
db.delayed_jobs_shard
|
68
|
+
end.compact.flatten.uniq # yes, all three
|
69
|
+
shard_dj_shards = [] unless ::Switchman::Shard.columns_hash.key?('delayed_jobs_shard_id')
|
70
|
+
shard_dj_shards ||= begin
|
71
|
+
::Switchman::Shard
|
72
|
+
.where.not(delayed_jobs_shard_id: nil)
|
73
|
+
.distinct
|
74
|
+
.pluck(:delayed_jobs_shard_id)
|
75
|
+
.map { |id| ::Switchman::Shard.lookup(id) }
|
76
|
+
.compact
|
77
|
+
end
|
78
|
+
(db_dj_shards + shard_dj_shards).uniq.sort
|
79
|
+
end
|
68
80
|
end
|
81
|
+
@delayed_jobs_shards
|
69
82
|
end
|
70
83
|
end
|
71
84
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: switchman-inst-jobs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Petty
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inst-jobs
|