switchman-inst-jobs 1.5.2 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/db/migrate/20101216224513_create_delayed_jobs.rb +42 -0
  3. data/db/migrate/20110208031356_add_delayed_jobs_tag.rb +14 -0
  4. data/db/migrate/20110426161613_add_delayed_jobs_max_attempts.rb +13 -0
  5. data/db/migrate/20110516225834_add_delayed_jobs_strand.rb +14 -0
  6. data/db/migrate/20110531144916_cleanup_delayed_jobs_indexes.rb +26 -0
  7. data/db/migrate/20110610213249_optimize_delayed_jobs.rb +40 -0
  8. data/db/migrate/20110831210257_add_delayed_jobs_next_in_strand.rb +52 -0
  9. data/db/migrate/20120510004759_delayed_jobs_delete_trigger_lock_for_update.rb +31 -0
  10. data/db/migrate/20120531150712_drop_psql_jobs_pop_fn.rb +15 -0
  11. data/db/migrate/20120607164022_delayed_jobs_use_advisory_locks.rb +80 -0
  12. data/db/migrate/20120607181141_index_jobs_on_locked_by.rb +15 -0
  13. data/db/migrate/20120608191051_add_jobs_run_at_index.rb +15 -0
  14. data/db/migrate/20120927184213_change_delayed_jobs_handler_to_text.rb +13 -0
  15. data/db/migrate/20140505215131_add_failed_jobs_original_job_id.rb +13 -0
  16. data/db/migrate/20140505215510_copy_failed_jobs_original_id.rb +12 -0
  17. data/db/migrate/20140505223637_drop_failed_jobs_original_id.rb +13 -0
  18. data/db/migrate/20140512213941_add_source_to_jobs.rb +15 -0
  19. data/db/migrate/20150807133223_add_max_concurrent_to_jobs.rb +70 -0
  20. data/db/migrate/20151123210429_add_expires_at_to_jobs.rb +15 -0
  21. data/db/migrate/20151210162949_improve_max_concurrent.rb +50 -0
  22. data/db/migrate/20161206323555_add_back_default_string_limits_jobs.rb +39 -0
  23. data/db/migrate/20181217155351_speed_up_max_concurrent_triggers.rb +95 -0
  24. data/db/migrate/20190726154743_make_critical_columns_not_null.rb +15 -0
  25. data/db/migrate/20200330230722_add_id_to_get_delayed_jobs_index.rb +25 -0
  26. data/db/migrate/20200824222232_speed_up_max_concurrent_delete_trigger.rb +94 -0
  27. data/db/migrate/20200825011002_add_strand_order_override.rb +126 -0
  28. data/lib/switchman_inst_jobs.rb +3 -3
  29. data/lib/switchman_inst_jobs/active_record/migration.rb +10 -0
  30. data/lib/switchman_inst_jobs/delayed/backend/base.rb +2 -2
  31. data/lib/switchman_inst_jobs/delayed/message_sending.rb +3 -2
  32. data/lib/switchman_inst_jobs/delayed/worker/health_check.rb +1 -3
  33. data/lib/switchman_inst_jobs/engine.rb +2 -2
  34. data/lib/switchman_inst_jobs/{shackles.rb → guard_rail.rb} +1 -1
  35. data/lib/switchman_inst_jobs/jobs_migrator.rb +9 -7
  36. data/lib/switchman_inst_jobs/version.rb +1 -1
  37. metadata +49 -30
  38. data/db/migrate/20180628153808_set_search_paths_on_functions.rb +0 -15
@@ -25,8 +25,8 @@ module SwitchmanInstJobs
25
25
  ::Object.include Delayed::MessageSending
26
26
  end
27
27
 
28
- def self.initialize_shackles
29
- ::Shackles.singleton_class.prepend Shackles::ClassMethods
28
+ def self.initialize_guard_rail
29
+ ::GuardRail.singleton_class.prepend GuardRail::ClassMethods
30
30
  end
31
31
 
32
32
  def self.initialize_switchman
@@ -44,9 +44,9 @@ require 'switchman_inst_jobs/delayed/pool'
44
44
  require 'switchman_inst_jobs/delayed/worker'
45
45
  require 'switchman_inst_jobs/delayed/worker/health_check'
46
46
  require 'switchman_inst_jobs/engine'
47
+ require 'switchman_inst_jobs/guard_rail'
47
48
  require 'switchman_inst_jobs/jobs_migrator'
48
49
  require 'switchman_inst_jobs/new_relic'
49
- require 'switchman_inst_jobs/shackles'
50
50
  require 'switchman_inst_jobs/switchman/database_server'
51
51
  require 'switchman_inst_jobs/switchman/default_shard'
52
52
  require 'switchman_inst_jobs/switchman/shard'
@@ -17,6 +17,16 @@ module SwitchmanInstJobs
17
17
  ensure
18
18
  ::ActiveRecord::Migration.open_migrations -= 1
19
19
  end
20
+
21
+ def copy(destination, sources, options = {})
22
+ if sources.delete('delayed_engine')
23
+ # rubocop:disable Rails/Output
24
+ puts 'NOTE: Not installing delayed_engine migrations in an application using switchman-inst-jobs'
25
+ puts '(use rake switchman_inst_jobs:install:migrations instead)'
26
+ # rubocop:enable Rails/Output
27
+ end
28
+ super
29
+ end
20
30
  end
21
31
  end
22
32
  end
@@ -12,13 +12,13 @@ module SwitchmanInstJobs
12
12
  module Backend
13
13
  module Base
14
14
  module ClassMethods
15
- def enqueue(object, options = {})
15
+ def enqueue(object, **options)
16
16
  ::Switchman::Shard.periodic_clear_shard_cache
17
17
  current_shard = ::Switchman::Shard.current
18
18
  enqueue_options = options.merge(
19
19
  current_shard: current_shard
20
20
  )
21
- enqueue_job = -> { ::Shackles.activate(:master) { super(object, enqueue_options) } }
21
+ enqueue_job = -> { ::GuardRail.activate(:master) { super(object, **enqueue_options) } }
22
22
 
23
23
  # Another dj shard must be currently manually activated, so just use that
24
24
  # In general this will only happen in unusual circumstances like tests
@@ -1,8 +1,9 @@
1
1
  module SwitchmanInstJobs
2
2
  module Delayed
3
3
  module MessageSending
4
- def send_later_enqueue_args(method, _enqueue_args = {}, *args)
5
- return send(method, *args) if ::Switchman::DatabaseServer.creating_new_shard
4
+ def delay(sender: nil, synchronous: false, **enqueue_args)
5
+ sender ||= __calculate_sender_for_delay
6
+ synchronous ||= ::Switchman::DatabaseServer.creating_new_shard
6
7
 
7
8
  super
8
9
  end
@@ -32,9 +32,7 @@ module SwitchmanInstJobs
32
32
  singleton = <<~SINGLETON
33
33
  periodic: Delayed::Worker::HealthCheck.reschedule_abandoned_jobs:#{shard.id}
34
34
  SINGLETON
35
- send_later_enqueue_args(
36
- :reschedule_abandoned_jobs, { singleton: singleton }, call_super: shard
37
- )
35
+ delay(singleton: singleton).reschedule_abandoned_jobs(call_super: shard)
38
36
  end
39
37
  end
40
38
  end
@@ -34,8 +34,8 @@ module SwitchmanInstJobs
34
34
  end
35
35
  end
36
36
 
37
- initializer 'sharding.shackles', after: 'switchman.extend_shackles' do
38
- SwitchmanInstJobs.initialize_shackles
37
+ initializer 'sharding.guard_rail', after: 'switchman.extend_guard_rail' do
38
+ SwitchmanInstJobs.initialize_guard_rail
39
39
  end
40
40
 
41
41
  initializer 'sharding.switchman' do
@@ -1,5 +1,5 @@
1
1
  module SwitchmanInstJobs
2
- module Shackles
2
+ module GuardRail
3
3
  module ClassMethods
4
4
  def activate(env, &block)
5
5
  if ::ActiveRecord::Migration.open_migrations.positive?
@@ -95,7 +95,7 @@ module SwitchmanInstJobs
95
95
  first = this_strand_scope.where('locked_by IS NOT NULL').next_in_strand_order.lock.first
96
96
  if first
97
97
  first_job = ::Delayed::Job.create!(strand: strand, next_in_strand: false)
98
- first_job.payload_object = ::Delayed::PerformableMethod.new(Kernel, :sleep, [0])
98
+ first_job.payload_object = ::Delayed::PerformableMethod.new(Kernel, :sleep, args: [0])
99
99
  first_job.queue = first.queue
100
100
  first_job.tag = 'Kernel.sleep'
101
101
  first_job.source = 'JobsMigrator::StrandBlocker'
@@ -183,12 +183,14 @@ module SwitchmanInstJobs
183
183
  # Adapted from get_and_lock_next_available in delayed/backend/active_record.rb
184
184
  target_jobs = scope.limit(1000).lock('FOR UPDATE SKIP LOCKED')
185
185
 
186
- query = "WITH limited_jobs AS (#{target_jobs.to_sql}) " \
187
- "UPDATE #{::Delayed::Job.quoted_table_name} " \
188
- "SET locked_by = #{::Delayed::Job.connection.quote(::Delayed::Backend::Base::ON_HOLD_LOCKED_BY)}, " \
189
- "locked_at = #{::Delayed::Job.connection.quote(::Delayed::Job.db_time_now)} "\
190
- "FROM limited_jobs WHERE limited_jobs.id=#{::Delayed::Job.quoted_table_name}.id " \
191
- "RETURNING #{::Delayed::Job.quoted_table_name}.*"
186
+ query = source_shard.activate(:delayed_jobs) do
187
+ "WITH limited_jobs AS (#{target_jobs.to_sql}) " \
188
+ "UPDATE #{::Delayed::Job.quoted_table_name} " \
189
+ "SET locked_by = #{::Delayed::Job.connection.quote(::Delayed::Backend::Base::ON_HOLD_LOCKED_BY)}, " \
190
+ "locked_at = #{::Delayed::Job.connection.quote(::Delayed::Job.db_time_now)} "\
191
+ "FROM limited_jobs WHERE limited_jobs.id=#{::Delayed::Job.quoted_table_name}.id " \
192
+ "RETURNING #{::Delayed::Job.quoted_table_name}.*"
193
+ end
192
194
 
193
195
  jobs = source_shard.activate(:delayed_jobs) { ::Delayed::Job.find_by_sql(query) }
194
196
  new_jobs = jobs.map do |job|
@@ -1,3 +1,3 @@
1
1
  module SwitchmanInstJobs
2
- VERSION = '1.5.2'.freeze
2
+ VERSION = '3.0.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,35 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: switchman-inst-jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 3.0.2
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: 2020-08-27 00:00:00.000000000 Z
11
+ date: 2020-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inst-jobs
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.16'
20
- - - "<"
19
+ version: '1.0'
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: '0.17'
22
+ version: 1.0.3
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ">="
27
+ - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: '0.16'
30
- - - "<"
29
+ version: '1.0'
30
+ - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: '0.17'
32
+ version: 1.0.3
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: parallel
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -68,22 +68,16 @@ dependencies:
68
68
  name: switchman
69
69
  requirement: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- version: '1.14'
74
- - - "<"
71
+ - - "~>"
75
72
  - !ruby/object:Gem::Version
76
- version: '1.16'
73
+ version: '2.0'
77
74
  type: :runtime
78
75
  prerelease: false
79
76
  version_requirements: !ruby/object:Gem::Requirement
80
77
  requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- version: '1.14'
84
- - - "<"
78
+ - - "~>"
85
79
  - !ruby/object:Gem::Version
86
- version: '1.16'
80
+ version: '2.0'
87
81
  - !ruby/object:Gem::Dependency
88
82
  name: bundler
89
83
  requirement: !ruby/object:Gem::Requirement
@@ -174,14 +168,14 @@ dependencies:
174
168
  requirements:
175
169
  - - "~>"
176
170
  - !ruby/object:Gem::Version
177
- version: '12'
171
+ version: '13'
178
172
  type: :development
179
173
  prerelease: false
180
174
  version_requirements: !ruby/object:Gem::Requirement
181
175
  requirements:
182
176
  - - "~>"
183
177
  - !ruby/object:Gem::Version
184
- version: '12'
178
+ version: '13'
185
179
  - !ruby/object:Gem::Dependency
186
180
  name: rspec
187
181
  requirement: !ruby/object:Gem::Requirement
@@ -266,17 +260,42 @@ dependencies:
266
260
  - - "~>"
267
261
  - !ruby/object:Gem::Version
268
262
  version: '1.4'
269
- description:
263
+ description:
270
264
  email:
271
265
  - bpetty@instructure.com
272
266
  executables: []
273
267
  extensions: []
274
268
  extra_rdoc_files: []
275
269
  files:
270
+ - db/migrate/20101216224513_create_delayed_jobs.rb
271
+ - db/migrate/20110208031356_add_delayed_jobs_tag.rb
272
+ - db/migrate/20110426161613_add_delayed_jobs_max_attempts.rb
273
+ - db/migrate/20110516225834_add_delayed_jobs_strand.rb
274
+ - db/migrate/20110531144916_cleanup_delayed_jobs_indexes.rb
275
+ - db/migrate/20110610213249_optimize_delayed_jobs.rb
276
+ - db/migrate/20110831210257_add_delayed_jobs_next_in_strand.rb
277
+ - db/migrate/20120510004759_delayed_jobs_delete_trigger_lock_for_update.rb
278
+ - db/migrate/20120531150712_drop_psql_jobs_pop_fn.rb
279
+ - db/migrate/20120607164022_delayed_jobs_use_advisory_locks.rb
280
+ - db/migrate/20120607181141_index_jobs_on_locked_by.rb
281
+ - db/migrate/20120608191051_add_jobs_run_at_index.rb
282
+ - db/migrate/20120927184213_change_delayed_jobs_handler_to_text.rb
283
+ - db/migrate/20140505215131_add_failed_jobs_original_job_id.rb
284
+ - db/migrate/20140505215510_copy_failed_jobs_original_id.rb
285
+ - db/migrate/20140505223637_drop_failed_jobs_original_id.rb
286
+ - db/migrate/20140512213941_add_source_to_jobs.rb
287
+ - db/migrate/20150807133223_add_max_concurrent_to_jobs.rb
288
+ - db/migrate/20151123210429_add_expires_at_to_jobs.rb
289
+ - db/migrate/20151210162949_improve_max_concurrent.rb
290
+ - db/migrate/20161206323555_add_back_default_string_limits_jobs.rb
276
291
  - db/migrate/20170308045400_add_shard_id_to_delayed_jobs.rb
277
- - db/migrate/20180628153808_set_search_paths_on_functions.rb
292
+ - db/migrate/20181217155351_speed_up_max_concurrent_triggers.rb
293
+ - db/migrate/20190726154743_make_critical_columns_not_null.rb
294
+ - db/migrate/20200330230722_add_id_to_get_delayed_jobs_index.rb
278
295
  - db/migrate/20200818130101_add_on_hold_to_switchman_shards.rb
279
296
  - db/migrate/20200822014259_add_block_stranded_to_switchman_shards.rb
297
+ - db/migrate/20200824222232_speed_up_max_concurrent_delete_trigger.rb
298
+ - db/migrate/20200825011002_add_strand_order_override.rb
280
299
  - lib/switchman-inst-jobs.rb
281
300
  - lib/switchman_inst_jobs.rb
282
301
  - lib/switchman_inst_jobs/active_record/connection_adapters/postgresql_adapter.rb
@@ -287,9 +306,9 @@ files:
287
306
  - lib/switchman_inst_jobs/delayed/worker.rb
288
307
  - lib/switchman_inst_jobs/delayed/worker/health_check.rb
289
308
  - lib/switchman_inst_jobs/engine.rb
309
+ - lib/switchman_inst_jobs/guard_rail.rb
290
310
  - lib/switchman_inst_jobs/jobs_migrator.rb
291
311
  - lib/switchman_inst_jobs/new_relic.rb
292
- - lib/switchman_inst_jobs/shackles.rb
293
312
  - lib/switchman_inst_jobs/switchman/database_server.rb
294
313
  - lib/switchman_inst_jobs/switchman/default_shard.rb
295
314
  - lib/switchman_inst_jobs/switchman/shard.rb
@@ -300,7 +319,7 @@ homepage: https://github.com/instructure/switchman-inst-jobs
300
319
  licenses:
301
320
  - MIT
302
321
  metadata: {}
303
- post_install_message:
322
+ post_install_message:
304
323
  rdoc_options: []
305
324
  require_paths:
306
325
  - lib
@@ -308,15 +327,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
308
327
  requirements:
309
328
  - - ">="
310
329
  - !ruby/object:Gem::Version
311
- version: '2.4'
330
+ version: '2.5'
312
331
  required_rubygems_version: !ruby/object:Gem::Requirement
313
332
  requirements:
314
333
  - - ">="
315
334
  - !ruby/object:Gem::Version
316
335
  version: '0'
317
336
  requirements: []
318
- rubygems_version: 3.0.3
319
- signing_key:
337
+ rubygems_version: 3.1.4
338
+ signing_key:
320
339
  specification_version: 4
321
340
  summary: Switchman and Instructure Jobs compatibility gem.
322
341
  test_files: []
@@ -1,15 +0,0 @@
1
- class SetSearchPathsOnFunctions < ActiveRecord::Migration[4.2]
2
- disable_ddl_transaction!
3
-
4
- def up
5
- set_search_path('delayed_jobs_after_delete_row_tr_fn', '()')
6
- set_search_path('delayed_jobs_before_insert_row_tr_fn', '()')
7
- set_search_path('half_md5_as_bigint', '(varchar)')
8
- end
9
-
10
- def down
11
- set_search_path('delayed_jobs_after_delete_row_tr_fn', '()', 'DEFAULT')
12
- set_search_path('delayed_jobs_before_insert_row_tr_fn', '()', 'DEFAULT')
13
- set_search_path('half_md5_as_bigint', '(varchar)', 'DEFAULT')
14
- end
15
- end