switchman-inst-jobs 1.2.0 → 1.2.1
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/backend/base.rb +3 -4
- data/lib/switchman_inst_jobs/delayed/worker/health_check.rb +12 -5
- data/lib/switchman_inst_jobs/engine.rb +2 -4
- data/lib/switchman_inst_jobs/switchman/shard.rb +6 -6
- data/lib/switchman_inst_jobs/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f3a0d265455c2a917a95287a0f7c768b0813d1a
|
4
|
+
data.tar.gz: 9a3bb7dc110aad2a9641d6c117f2a3fcbd1428e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de054363463c33fecec8950c1ac38357650217665cbddaa45e9c54df6baa3dfe7bd4065f304a4a518ebbc59e96bf739afcceb2c5072795d57ce258fc6d667450
|
7
|
+
data.tar.gz: 3547050ecabf7d90c5fff12ca6e2307959edbcedc63b7729ccf6e84cc4745eae99e4edf9b572c590f93adf5b8c619a6116f3671126c9034a6280be9c641dadd2
|
@@ -27,7 +27,8 @@ module SwitchmanInstJobs
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def configured_shard_ids
|
30
|
-
(::Delayed::Settings.worker_config.try(:[],
|
30
|
+
(::Delayed::Settings.worker_config.try(:[], 'workers') || [])
|
31
|
+
.map { |w| w['shard'] }.compact.uniq
|
31
32
|
end
|
32
33
|
|
33
34
|
def processes_locked_locally
|
@@ -68,9 +69,7 @@ module SwitchmanInstJobs
|
|
68
69
|
# likely a missing shard with a stale cache
|
69
70
|
current_shard.send(:clear_cache)
|
70
71
|
::Switchman::Shard.clear_cache
|
71
|
-
unless ::Switchman::Shard.where(id: shard_id).exists?
|
72
|
-
raise ShardNotFoundError, shard_id
|
73
|
-
end
|
72
|
+
raise ShardNotFoundError, shard_id unless ::Switchman::Shard.where(id: shard_id).exists?
|
74
73
|
raise
|
75
74
|
end
|
76
75
|
end
|
@@ -10,7 +10,9 @@ module SwitchmanInstJobs
|
|
10
10
|
def munge_service_name(shard)
|
11
11
|
# munge the name to add the current shard
|
12
12
|
original_service_name = ::Delayed::Settings.worker_health_check_config['service_name']
|
13
|
-
|
13
|
+
consul_service_name = ::Delayed::Worker::ConsulHealthCheck::DEFAULT_SERVICE_NAME
|
14
|
+
::Delayed::Settings.worker_health_check_config['service_name'] =
|
15
|
+
"#{original_service_name || consul_service_name}/#{shard.id}"
|
14
16
|
yield
|
15
17
|
ensure
|
16
18
|
::Delayed::Settings.worker_health_check_config['service_name'] = original_service_name
|
@@ -19,12 +21,17 @@ module SwitchmanInstJobs
|
|
19
21
|
def reschedule_abandoned_jobs(call_super: false)
|
20
22
|
shards = ::Switchman::Shard.delayed_jobs_shards
|
21
23
|
call_super = true if shards.length == 1
|
22
|
-
|
24
|
+
if call_super
|
25
|
+
return munge_service_name(::Switchman::Shard.current(:delayed_jobs)) { super() }
|
26
|
+
end
|
23
27
|
|
24
28
|
::Switchman::Shard.with_each_shard(shards, [:delayed_jobs]) do
|
25
|
-
|
26
|
-
|
27
|
-
|
29
|
+
singleton = <<~SINGLETON
|
30
|
+
periodic: Delayed::Worker::HealthCheck.reschedule_abandoned_jobs:#{::Switchman::Shard.current(:delayed_jobs).id}
|
31
|
+
SINGLETON
|
32
|
+
send_later_enqueue_args(
|
33
|
+
:reschedule_abandoned_jobs, { singleton: singleton }, call_super: true
|
34
|
+
)
|
28
35
|
end
|
29
36
|
end
|
30
37
|
end
|
@@ -2,8 +2,7 @@ module SwitchmanInstJobs
|
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
isolate_namespace SwitchmanInstJobs
|
4
4
|
|
5
|
-
initializer 'sharding.active_record',
|
6
|
-
after: 'switchman.extend_connection_adapters' do
|
5
|
+
initializer 'sharding.active_record', after: 'switchman.extend_connection_adapters' do
|
7
6
|
SwitchmanInstJobs.initialize_active_record
|
8
7
|
end
|
9
8
|
|
@@ -11,8 +10,7 @@ module SwitchmanInstJobs
|
|
11
10
|
SwitchmanInstJobs.initialize_inst_jobs
|
12
11
|
end
|
13
12
|
|
14
|
-
initializer 'sharding.shackles',
|
15
|
-
after: 'switchman.extend_shackles' do
|
13
|
+
initializer 'sharding.shackles', after: 'switchman.extend_shackles' do
|
16
14
|
SwitchmanInstJobs.initialize_shackles
|
17
15
|
end
|
18
16
|
|
@@ -58,12 +58,12 @@ module SwitchmanInstJobs
|
|
58
58
|
next db.shards.to_a if db.config[:delayed_jobs_shard] == 'self'
|
59
59
|
db.delayed_jobs_shard
|
60
60
|
end.compact.flatten.uniq # yes, all three
|
61
|
-
shard_dj_shards = ::Switchman::Shard
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
61
|
+
shard_dj_shards = ::Switchman::Shard
|
62
|
+
.where.not(delayed_jobs_shard_id: nil)
|
63
|
+
.distinct
|
64
|
+
.pluck(:delayed_jobs_shard_id)
|
65
|
+
.map { |id| ::Switchman::Shard.lookup(id) }
|
66
|
+
.compact
|
67
67
|
(db_dj_shards + shard_dj_shards).uniq.sort
|
68
68
|
end
|
69
69
|
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.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Petty
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inst-jobs
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 0.12.1
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '0.
|
22
|
+
version: '0.16'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: 0.12.1
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '0.
|
32
|
+
version: '0.16'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: railties
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -188,14 +188,14 @@ dependencies:
|
|
188
188
|
requirements:
|
189
189
|
- - "~>"
|
190
190
|
- !ruby/object:Gem::Version
|
191
|
-
version:
|
191
|
+
version: 0.57.2
|
192
192
|
type: :development
|
193
193
|
prerelease: false
|
194
194
|
version_requirements: !ruby/object:Gem::Requirement
|
195
195
|
requirements:
|
196
196
|
- - "~>"
|
197
197
|
- !ruby/object:Gem::Version
|
198
|
-
version:
|
198
|
+
version: 0.57.2
|
199
199
|
- !ruby/object:Gem::Dependency
|
200
200
|
name: simplecov
|
201
201
|
requirement: !ruby/object:Gem::Requirement
|