switchman-inst-jobs 4.0.15 → 4.0.16

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: e78746649c51edcf059596423923bc4f42422108877a1c7444aa7985c7a55065
4
- data.tar.gz: c553969dbfb2b7bc796ad2b10c7589ef08fb063246601ad38a6484ab89486125
3
+ metadata.gz: ffde0df8a9f25e9d0feeb77a63670fbbfd0f9dd3a407ed1f6419070f66c2674f
4
+ data.tar.gz: c31ecdea96e9759783ce4f3683eb57f7f156bd68f053537063cb10a5d4351dc4
5
5
  SHA512:
6
- metadata.gz: b95a14b6122193c204642643608a7355cbdb2abb69fec3471021788c31bcd0ffccd1d811f69b86a5a4cda47c7a43b25eb22a59d5f13a6d73bb07cadf659246a0
7
- data.tar.gz: 693d7faaf636a13445c097d2faa0e5c45b0b1a31ed3245c0e43334f7dc19efd08bcc6491f1432e8afc17124edb433fc2cd06c61f9a4bf70ecb1e5f03e0d2b5ad
6
+ metadata.gz: 7b324b5616dfbd26e6af0c3ce2182f3a2fa66423eb672b842b51f19b9088be7befd31484d5e1290990506d6867471ea38e9d6303cf233538589c8c2c0626b9e2
7
+ data.tar.gz: 7c7e9928a25641dd790464a77d04078d467a006e30dcb6dfcce8b24860cb0f441273e164679d5cdc3d718b5b21ff225aee013c71716a599e3985aa09853a5931
@@ -3,8 +3,17 @@
3
3
  module SwitchmanInstJobs
4
4
  module Delayed
5
5
  module Pool
6
+ def initialize(*)
7
+ super
8
+
9
+ raise "Cannot run jobs cross-region" unless shards.all?(&:in_current_region?)
10
+ end
11
+
6
12
  def unlock_orphaned_jobs(worker = nil, pid = nil)
7
13
  if worker
14
+ # this is just a failsafe; it shouldn't be possible
15
+ return unless worker.shard.in_current_region?
16
+
8
17
  shards = [worker.shard]
9
18
  else
10
19
  # Since we're not unlocking for a specific worker, look through
@@ -19,13 +28,18 @@ module SwitchmanInstJobs
19
28
  # We purposely don't .compact to remove nils here, since if any
20
29
  # workers are on the default jobs shard we want to unlock against
21
30
  # that shard too.
22
- shard_ids = @config[:workers].pluck(:shard).uniq
23
- shards = shard_ids.map { |shard_id| ::Delayed::Worker.shard(shard_id) }
31
+
32
+ shards = self.shards.select(&:in_current_region?)
24
33
  end
25
34
  ::Switchman::Shard.with_each_shard(shards, [::Delayed::Backend::ActiveRecord::AbstractJob]) do
26
35
  super
27
36
  end
28
37
  end
38
+
39
+ def shards
40
+ shard_ids = @config[:workers].pluck(:shard).uniq
41
+ shard_ids.map { |shard_id| ::Delayed::Worker.shard(shard_id) }
42
+ end
29
43
  end
30
44
  end
31
45
  end
@@ -10,6 +10,9 @@ module SwitchmanInstJobs
10
10
  def initialize(options = {})
11
11
  # have to initialize this first, so #shard works
12
12
  @config = options
13
+ # this shouldn't be possible because of the pool check, but just in case
14
+ raise "Cannot run jobs cross-region" unless shard.in_current_region?
15
+
13
16
  ::Delayed::Worker::HealthCheck.munge_service_name(shard) do
14
17
  super
15
18
  # ensure we get our own copy of the munged config
@@ -120,8 +120,7 @@ module SwitchmanInstJobs
120
120
  scope = scope.or(::Switchman::Shard.unscoped.where(id: db_jobs_shards)) unless db_jobs_shards.empty?
121
121
 
122
122
  if has_self
123
- self_dbs = ::Switchman::DatabaseServer.all
124
- .select { |db| db.config[:delayed_jobs_shard] == "self" }.map(&:id)
123
+ self_dbs = ::Switchman::DatabaseServer.select { |db| db.config[:delayed_jobs_shard] == "self" }.map(&:id)
125
124
  scope = scope.or(::Switchman::Shard.unscoped
126
125
  .where(id: ::Switchman::Shard.unscoped.where(delayed_jobs_shard_id: nil, database_server_id: self_dbs)
127
126
  .select(:id)))
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SwitchmanInstJobs
4
- VERSION = "4.0.15"
4
+ VERSION = "4.0.16"
5
5
  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: 4.0.15
4
+ version: 4.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Petty
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-06 00:00:00.000000000 Z
11
+ date: 2023-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inst-jobs
@@ -71,6 +71,9 @@ dependencies:
71
71
  - - "~>"
72
72
  - !ruby/object:Gem::Version
73
73
  version: '3.1'
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 3.5.14
74
77
  type: :runtime
75
78
  prerelease: false
76
79
  version_requirements: !ruby/object:Gem::Requirement
@@ -78,6 +81,9 @@ dependencies:
78
81
  - - "~>"
79
82
  - !ruby/object:Gem::Version
80
83
  version: '3.1'
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 3.5.14
81
87
  - !ruby/object:Gem::Dependency
82
88
  name: bundler
83
89
  requirement: !ruby/object:Gem::Requirement
@@ -274,7 +280,7 @@ dependencies:
274
280
  - - "~>"
275
281
  - !ruby/object:Gem::Version
276
282
  version: '0.21'
277
- description:
283
+ description:
278
284
  email:
279
285
  - bpetty@instructure.com
280
286
  executables: []
@@ -353,7 +359,7 @@ licenses:
353
359
  metadata:
354
360
  allowed_push_host: https://rubygems.org
355
361
  rubygems_mfa_required: 'true'
356
- post_install_message:
362
+ post_install_message:
357
363
  rdoc_options: []
358
364
  require_paths:
359
365
  - lib
@@ -368,8 +374,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
368
374
  - !ruby/object:Gem::Version
369
375
  version: '0'
370
376
  requirements: []
371
- rubygems_version: 3.1.6
372
- signing_key:
377
+ rubygems_version: 3.4.19
378
+ signing_key:
373
379
  specification_version: 4
374
380
  summary: Switchman and Instructure Jobs compatibility gem.
375
381
  test_files: []