inst-jobs 2.2.1 → 2.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/db/migrate/20101216224513_create_delayed_jobs.rb +9 -7
  3. data/db/migrate/20110531144916_cleanup_delayed_jobs_indexes.rb +8 -13
  4. data/db/migrate/20110610213249_optimize_delayed_jobs.rb +8 -8
  5. data/db/migrate/20110831210257_add_delayed_jobs_next_in_strand.rb +25 -25
  6. data/db/migrate/20120510004759_delayed_jobs_delete_trigger_lock_for_update.rb +4 -8
  7. data/db/migrate/20120531150712_drop_psql_jobs_pop_fn.rb +1 -3
  8. data/db/migrate/20120607164022_delayed_jobs_use_advisory_locks.rb +11 -15
  9. data/db/migrate/20120607181141_index_jobs_on_locked_by.rb +1 -1
  10. data/db/migrate/20120608191051_add_jobs_run_at_index.rb +2 -2
  11. data/db/migrate/20120927184213_change_delayed_jobs_handler_to_text.rb +1 -1
  12. data/db/migrate/20140505215510_copy_failed_jobs_original_id.rb +2 -3
  13. data/db/migrate/20150807133223_add_max_concurrent_to_jobs.rb +9 -13
  14. data/db/migrate/20151210162949_improve_max_concurrent.rb +4 -8
  15. data/db/migrate/20161206323555_add_back_default_string_limits_jobs.rb +3 -2
  16. data/db/migrate/20181217155351_speed_up_max_concurrent_triggers.rb +13 -17
  17. data/db/migrate/20200330230722_add_id_to_get_delayed_jobs_index.rb +8 -8
  18. data/db/migrate/20200824222232_speed_up_max_concurrent_delete_trigger.rb +72 -77
  19. data/db/migrate/20200825011002_add_strand_order_override.rb +93 -97
  20. data/db/migrate/20210809145804_add_n_strand_index.rb +12 -0
  21. data/db/migrate/20210812210128_add_singleton_column.rb +203 -0
  22. data/exe/inst_jobs +3 -2
  23. data/lib/delayed/backend/active_record.rb +187 -159
  24. data/lib/delayed/backend/base.rb +80 -69
  25. data/lib/delayed/batch.rb +11 -9
  26. data/lib/delayed/cli.rb +98 -84
  27. data/lib/delayed/core_ext/kernel.rb +4 -2
  28. data/lib/delayed/daemon.rb +70 -74
  29. data/lib/delayed/job_tracking.rb +26 -25
  30. data/lib/delayed/lifecycle.rb +27 -24
  31. data/lib/delayed/log_tailer.rb +17 -17
  32. data/lib/delayed/logging.rb +13 -16
  33. data/lib/delayed/message_sending.rb +42 -51
  34. data/lib/delayed/performable_method.rb +5 -7
  35. data/lib/delayed/periodic.rb +66 -65
  36. data/lib/delayed/plugin.rb +2 -4
  37. data/lib/delayed/pool.rb +198 -192
  38. data/lib/delayed/server/helpers.rb +6 -6
  39. data/lib/delayed/server.rb +51 -54
  40. data/lib/delayed/settings.rb +93 -81
  41. data/lib/delayed/testing.rb +21 -22
  42. data/lib/delayed/version.rb +1 -1
  43. data/lib/delayed/work_queue/in_process.rb +21 -17
  44. data/lib/delayed/work_queue/parent_process/client.rb +55 -53
  45. data/lib/delayed/work_queue/parent_process/server.rb +215 -209
  46. data/lib/delayed/work_queue/parent_process.rb +52 -53
  47. data/lib/delayed/worker/consul_health_check.rb +21 -19
  48. data/lib/delayed/worker/health_check.rb +21 -12
  49. data/lib/delayed/worker/null_health_check.rb +3 -1
  50. data/lib/delayed/worker/process_helper.rb +8 -9
  51. data/lib/delayed/worker.rb +271 -261
  52. data/lib/delayed/yaml_extensions.rb +12 -10
  53. data/lib/delayed_job.rb +37 -37
  54. data/lib/inst-jobs.rb +1 -1
  55. data/spec/active_record_job_spec.rb +142 -138
  56. data/spec/delayed/cli_spec.rb +7 -7
  57. data/spec/delayed/daemon_spec.rb +8 -8
  58. data/spec/delayed/message_sending_spec.rb +8 -9
  59. data/spec/delayed/periodic_spec.rb +13 -12
  60. data/spec/delayed/server_spec.rb +38 -38
  61. data/spec/delayed/settings_spec.rb +26 -25
  62. data/spec/delayed/work_queue/in_process_spec.rb +7 -7
  63. data/spec/delayed/work_queue/parent_process/client_spec.rb +16 -12
  64. data/spec/delayed/work_queue/parent_process/server_spec.rb +43 -40
  65. data/spec/delayed/work_queue/parent_process_spec.rb +21 -21
  66. data/spec/delayed/worker/consul_health_check_spec.rb +22 -22
  67. data/spec/delayed/worker/health_check_spec.rb +51 -49
  68. data/spec/delayed/worker_spec.rb +28 -25
  69. data/spec/gemfiles/52.gemfile +5 -3
  70. data/spec/gemfiles/52.gemfile.lock +240 -0
  71. data/spec/gemfiles/60.gemfile +5 -3
  72. data/spec/gemfiles/60.gemfile.lock +246 -0
  73. data/spec/gemfiles/61.gemfile +9 -0
  74. data/spec/sample_jobs.rb +45 -15
  75. data/spec/shared/delayed_batch.rb +74 -67
  76. data/spec/shared/delayed_method.rb +143 -102
  77. data/spec/shared/performable_method.rb +39 -38
  78. data/spec/shared/shared_backend.rb +537 -437
  79. data/spec/shared/testing.rb +14 -14
  80. data/spec/shared/worker.rb +156 -148
  81. data/spec/shared_jobs_specs.rb +13 -13
  82. data/spec/spec_helper.rb +43 -51
  83. metadata +101 -70
  84. data/lib/delayed/backend/redis/bulk_update.lua +0 -50
  85. data/lib/delayed/backend/redis/destroy_job.lua +0 -2
  86. data/lib/delayed/backend/redis/enqueue.lua +0 -29
  87. data/lib/delayed/backend/redis/fail_job.lua +0 -5
  88. data/lib/delayed/backend/redis/find_available.lua +0 -3
  89. data/lib/delayed/backend/redis/functions.rb +0 -59
  90. data/lib/delayed/backend/redis/get_and_lock_next_available.lua +0 -17
  91. data/lib/delayed/backend/redis/includes/jobs_common.lua +0 -203
  92. data/lib/delayed/backend/redis/job.rb +0 -535
  93. data/lib/delayed/backend/redis/set_running.lua +0 -5
  94. data/lib/delayed/backend/redis/tickle_strand.lua +0 -2
  95. data/spec/gemfiles/42.gemfile +0 -7
  96. data/spec/gemfiles/50.gemfile +0 -7
  97. data/spec/gemfiles/51.gemfile +0 -7
  98. data/spec/redis_job_spec.rb +0 -148
data/spec/spec_helper.rb CHANGED
@@ -1,21 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'delayed_job'
4
- require 'delayed/testing'
3
+ require "delayed_job"
4
+ require "delayed/testing"
5
5
 
6
- require 'database_cleaner'
7
- require 'rack/test'
8
- require 'test_after_commit' if ::Rails.version < '5'
9
- require 'timecop'
10
- require 'webmock/rspec'
6
+ require "database_cleaner"
7
+ require "rack/test"
8
+ require "timecop"
9
+ require "webmock/rspec"
11
10
 
12
- require 'pry'
13
- require 'byebug'
11
+ require "pry"
12
+ require "byebug"
14
13
 
15
14
  RSpec.configure do |config|
16
-
17
15
  config.expect_with(:rspec) do |c|
18
- c.syntax = [:should, :expect]
16
+ c.syntax = %i[should expect]
19
17
  end
20
18
 
21
19
  config.before(:suite) do
@@ -24,57 +22,42 @@ RSpec.configure do |config|
24
22
  WebMock.disable_net_connect!
25
23
  end
26
24
 
27
- config.before(:each) do |example|
28
- if Delayed::Backend::Redis::Job.redis
29
- Delayed::Backend::Redis::Job.redis.flushdb
30
- end
31
- DatabaseCleaner.strategy = (example.metadata[:sinatra] || example.metadata[:non_transactional]) ?
32
- :truncation : :transaction
25
+ config.before do |example|
26
+ DatabaseCleaner.strategy = if example.metadata[:sinatra] || example.metadata[:non_transactional]
27
+ :truncation
28
+ else
29
+ :transaction
30
+ end
33
31
  DatabaseCleaner.start
34
32
  end
35
33
 
36
- config.after(:each) do
34
+ config.after do
37
35
  DatabaseCleaner.clean
38
36
  end
39
37
  end
40
38
 
41
39
  module NoYamlDump
42
- def encode_with(coder)
43
- end
40
+ def encode_with(coder); end
44
41
  end
45
42
  # example groups are often the sender, and if we try to serialize them,
46
43
  # the resultant object is then encoded in the sender, and then we serialize
47
44
  # again, and it just keeps getting bigger and bigger and bigger...
48
45
  RSpec::Core::ExampleGroup.include(NoYamlDump)
49
46
 
50
- ENV['TEST_ENV_NUMBER'] ||= '1'
51
- ENV['TEST_DB_HOST'] ||= 'localhost'
52
- ENV['TEST_DB_DATABASE'] ||= "inst-jobs-test-#{ENV['TEST_ENV_NUMBER']}"
53
- ENV['TEST_REDIS_CONNECTION'] ||= 'redis://localhost:6379/'
54
-
55
- Delayed::Backend::Redis::Job.redis = Redis.new(url: ENV['TEST_REDIS_CONNECTION'])
56
- Delayed::Backend::Redis::Job.redis.select ENV['TEST_ENV_NUMBER']
47
+ ENV["TEST_ENV_NUMBER"] ||= "1"
48
+ ENV["TEST_DB_HOST"] ||= "localhost"
49
+ ENV["TEST_DB_DATABASE"] ||= "inst-jobs-test-#{ENV['TEST_ENV_NUMBER']}"
57
50
 
58
51
  connection_config = {
59
52
  adapter: :postgresql,
60
- host: ENV['TEST_DB_HOST'].presence,
61
- encoding: 'utf8',
62
- username: ENV['TEST_DB_USERNAME'],
63
- database: ENV['TEST_DB_DATABASE'],
53
+ host: ENV["TEST_DB_HOST"].presence,
54
+ encoding: "utf8",
55
+ username: ENV["TEST_DB_USERNAME"],
56
+ database: ENV["TEST_DB_DATABASE"]
64
57
  }
65
58
 
66
- if ::Rails.version < '5'
67
- class ActiveRecord::Migration
68
- class << self
69
- def [](_version); self; end
70
- end
71
- end
72
- end
73
-
74
59
  def migrate(file)
75
- if ::Rails.version < '5.2'
76
- ActiveRecord::Migrator.migrate(file)
77
- elsif ::Rails.version >= '6'
60
+ if ::Rails.version >= "6"
78
61
  ActiveRecord::MigrationContext.new(file, ActiveRecord::SchemaMigration).migrate
79
62
  else
80
63
  ActiveRecord::MigrationContext.new(file).migrate
@@ -82,27 +65,36 @@ def migrate(file)
82
65
  end
83
66
 
84
67
  # create the test db if it does not exist, to help out wwtd
85
- ActiveRecord::Base.establish_connection(connection_config.merge(database: 'postgres'))
68
+ ActiveRecord::Base.establish_connection(connection_config.merge(database: "postgres"))
86
69
  begin
87
70
  ActiveRecord::Base.connection.create_database(connection_config[:database])
88
71
  rescue ActiveRecord::StatementInvalid
72
+ nil
89
73
  end
90
74
  ActiveRecord::Base.establish_connection(connection_config)
91
- # TODO reset db and migrate again, to test migrations
75
+ # TODO: reset db and migrate again, to test migrations
92
76
 
93
77
  migrate("db/migrate")
94
78
  migrate("spec/migrate")
95
79
  Delayed::Backend::ActiveRecord::Job.reset_column_information
96
80
  Delayed::Backend::ActiveRecord::Job::Failed.reset_column_information
97
81
 
98
- Time.zone = 'UTC'
82
+ Time.zone = "UTC" # rubocop:disable Rails/TimeZoneAssignment
99
83
  Rails.logger = Logger.new(nil)
100
84
 
101
85
  # Purely useful for test cases...
102
86
  class Story < ActiveRecord::Base
103
- def tell; text; end
104
- def whatever(n, _); tell*n; end
105
- def whatever_else(n, _); tell*n; end
87
+ def tell
88
+ text
89
+ end
90
+
91
+ def whatever(times, _)
92
+ tell * times
93
+ end
94
+
95
+ def whatever_else(times, _)
96
+ tell * times
97
+ end
106
98
 
107
99
  handle_asynchronously :whatever
108
100
  handle_asynchronously :whatever_else, queue: "testqueue"
@@ -125,7 +117,7 @@ module MyReverser
125
117
  end
126
118
 
127
119
  def change_setting(klass, setting_name, value)
128
- old_val = klass.class_variable_get(:"@@#{setting_name}")
120
+ old_val = klass.send(setting_name)
129
121
  klass.send("#{setting_name}=", value)
130
122
  yield
131
123
  ensure
@@ -136,5 +128,5 @@ def run_job(job)
136
128
  Delayed::Testing.run_job(job)
137
129
  end
138
130
 
139
- require File.expand_path('../sample_jobs', __FILE__)
140
- require File.expand_path('../shared_jobs_specs', __FILE__)
131
+ require_relative "sample_jobs"
132
+ require_relative "shared_jobs_specs"
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: 2.2.1
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Luetke
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-02-19 00:00:00.000000000 Z
12
+ date: 2021-09-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -17,28 +17,28 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '4.2'
20
+ version: '5.2'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '4.2'
27
+ version: '5.2'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: activesupport
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: '4.2'
34
+ version: '5.2'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: '4.2'
41
+ version: '5.2'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: after_transaction_commit
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -60,47 +60,19 @@ dependencies:
60
60
  - !ruby/object:Gem::Version
61
61
  version: '3'
62
62
  - !ruby/object:Gem::Dependency
63
- name: railties
64
- requirement: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '4.2'
69
- type: :runtime
70
- prerelease: false
71
- version_requirements: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '4.2'
76
- - !ruby/object:Gem::Dependency
77
- name: redis
78
- requirement: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">"
81
- - !ruby/object:Gem::Version
82
- version: '3.0'
83
- type: :runtime
84
- prerelease: false
85
- version_requirements: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">"
88
- - !ruby/object:Gem::Version
89
- version: '3.0'
90
- - !ruby/object:Gem::Dependency
91
- name: redis-scripting
63
+ name: debug_inspector
92
64
  requirement: !ruby/object:Gem::Requirement
93
65
  requirements:
94
66
  - - "~>"
95
67
  - !ruby/object:Gem::Version
96
- version: 1.0.1
68
+ version: '1.0'
97
69
  type: :runtime
98
70
  prerelease: false
99
71
  version_requirements: !ruby/object:Gem::Requirement
100
72
  requirements:
101
73
  - - "~>"
102
74
  - !ruby/object:Gem::Version
103
- version: 1.0.1
75
+ version: '1.0'
104
76
  - !ruby/object:Gem::Dependency
105
77
  name: fugit
106
78
  requirement: !ruby/object:Gem::Requirement
@@ -116,19 +88,19 @@ dependencies:
116
88
  - !ruby/object:Gem::Version
117
89
  version: '1.3'
118
90
  - !ruby/object:Gem::Dependency
119
- name: debug_inspector
91
+ name: railties
120
92
  requirement: !ruby/object:Gem::Requirement
121
93
  requirements:
122
- - - "~>"
94
+ - - ">="
123
95
  - !ruby/object:Gem::Version
124
- version: 0.0.3
96
+ version: '5.2'
125
97
  type: :runtime
126
98
  prerelease: false
127
99
  version_requirements: !ruby/object:Gem::Requirement
128
100
  requirements:
129
- - - "~>"
101
+ - - ">="
130
102
  - !ruby/object:Gem::Version
131
- version: 0.0.3
103
+ version: '5.2'
132
104
  - !ruby/object:Gem::Dependency
133
105
  name: bump
134
106
  requirement: !ruby/object:Gem::Requirement
@@ -161,16 +133,30 @@ dependencies:
161
133
  name: database_cleaner
162
134
  requirement: !ruby/object:Gem::Requirement
163
135
  requirements:
164
- - - '='
136
+ - - "~>"
165
137
  - !ruby/object:Gem::Version
166
- version: 1.6.1
138
+ version: '2.0'
167
139
  type: :development
168
140
  prerelease: false
169
141
  version_requirements: !ruby/object:Gem::Requirement
170
142
  requirements:
171
- - - '='
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '2.0'
146
+ - !ruby/object:Gem::Dependency
147
+ name: database_cleaner-active_record
148
+ requirement: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '2.0'
153
+ type: :development
154
+ prerelease: false
155
+ version_requirements: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
172
158
  - !ruby/object:Gem::Version
173
- version: 1.6.1
159
+ version: '2.0'
174
160
  - !ruby/object:Gem::Dependency
175
161
  name: diplomat
176
162
  requirement: !ruby/object:Gem::Requirement
@@ -261,14 +247,70 @@ dependencies:
261
247
  requirements:
262
248
  - - "~>"
263
249
  - !ruby/object:Gem::Version
264
- version: 3.8.0
250
+ version: '3.10'
251
+ type: :development
252
+ prerelease: false
253
+ version_requirements: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - "~>"
256
+ - !ruby/object:Gem::Version
257
+ version: '3.10'
258
+ - !ruby/object:Gem::Dependency
259
+ name: rubocop
260
+ requirement: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - "~>"
263
+ - !ruby/object:Gem::Version
264
+ version: '1.19'
265
+ type: :development
266
+ prerelease: false
267
+ version_requirements: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - "~>"
270
+ - !ruby/object:Gem::Version
271
+ version: '1.19'
272
+ - !ruby/object:Gem::Dependency
273
+ name: rubocop-rails
274
+ requirement: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - "~>"
277
+ - !ruby/object:Gem::Version
278
+ version: '2.11'
279
+ type: :development
280
+ prerelease: false
281
+ version_requirements: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - "~>"
284
+ - !ruby/object:Gem::Version
285
+ version: '2.11'
286
+ - !ruby/object:Gem::Dependency
287
+ name: rubocop-rake
288
+ requirement: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - "~>"
291
+ - !ruby/object:Gem::Version
292
+ version: '0.6'
293
+ type: :development
294
+ prerelease: false
295
+ version_requirements: !ruby/object:Gem::Requirement
296
+ requirements:
297
+ - - "~>"
298
+ - !ruby/object:Gem::Version
299
+ version: '0.6'
300
+ - !ruby/object:Gem::Dependency
301
+ name: rubocop-rspec
302
+ requirement: !ruby/object:Gem::Requirement
303
+ requirements:
304
+ - - "~>"
305
+ - !ruby/object:Gem::Version
306
+ version: '2.4'
265
307
  type: :development
266
308
  prerelease: false
267
309
  version_requirements: !ruby/object:Gem::Requirement
268
310
  requirements:
269
311
  - - "~>"
270
312
  - !ruby/object:Gem::Version
271
- version: 3.8.0
313
+ version: '2.4'
272
314
  - !ruby/object:Gem::Dependency
273
315
  name: sinatra
274
316
  requirement: !ruby/object:Gem::Requirement
@@ -303,14 +345,14 @@ dependencies:
303
345
  requirements:
304
346
  - - '='
305
347
  - !ruby/object:Gem::Version
306
- version: 0.7.1
348
+ version: 0.9.4
307
349
  type: :development
308
350
  prerelease: false
309
351
  version_requirements: !ruby/object:Gem::Requirement
310
352
  requirements:
311
353
  - - '='
312
354
  - !ruby/object:Gem::Version
313
- version: 0.7.1
355
+ version: 0.9.4
314
356
  - !ruby/object:Gem::Dependency
315
357
  name: webmock
316
358
  requirement: !ruby/object:Gem::Requirement
@@ -373,20 +415,11 @@ files:
373
415
  - db/migrate/20200330230722_add_id_to_get_delayed_jobs_index.rb
374
416
  - db/migrate/20200824222232_speed_up_max_concurrent_delete_trigger.rb
375
417
  - db/migrate/20200825011002_add_strand_order_override.rb
418
+ - db/migrate/20210809145804_add_n_strand_index.rb
419
+ - db/migrate/20210812210128_add_singleton_column.rb
376
420
  - exe/inst_jobs
377
421
  - lib/delayed/backend/active_record.rb
378
422
  - lib/delayed/backend/base.rb
379
- - lib/delayed/backend/redis/bulk_update.lua
380
- - lib/delayed/backend/redis/destroy_job.lua
381
- - lib/delayed/backend/redis/enqueue.lua
382
- - lib/delayed/backend/redis/fail_job.lua
383
- - lib/delayed/backend/redis/find_available.lua
384
- - lib/delayed/backend/redis/functions.rb
385
- - lib/delayed/backend/redis/get_and_lock_next_available.lua
386
- - lib/delayed/backend/redis/includes/jobs_common.lua
387
- - lib/delayed/backend/redis/job.rb
388
- - lib/delayed/backend/redis/set_running.lua
389
- - lib/delayed/backend/redis/tickle_strand.lua
390
423
  - lib/delayed/batch.rb
391
424
  - lib/delayed/cli.rb
392
425
  - lib/delayed/core_ext/kernel.rb
@@ -436,13 +469,12 @@ files:
436
469
  - spec/delayed/worker/consul_health_check_spec.rb
437
470
  - spec/delayed/worker/health_check_spec.rb
438
471
  - spec/delayed/worker_spec.rb
439
- - spec/gemfiles/42.gemfile
440
- - spec/gemfiles/50.gemfile
441
- - spec/gemfiles/51.gemfile
442
472
  - spec/gemfiles/52.gemfile
473
+ - spec/gemfiles/52.gemfile.lock
443
474
  - spec/gemfiles/60.gemfile
475
+ - spec/gemfiles/60.gemfile.lock
476
+ - spec/gemfiles/61.gemfile
444
477
  - spec/migrate/20140924140513_add_story_table.rb
445
- - spec/redis_job_spec.rb
446
478
  - spec/sample_jobs.rb
447
479
  - spec/shared/delayed_batch.rb
448
480
  - spec/shared/delayed_method.rb
@@ -470,19 +502,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
470
502
  - !ruby/object:Gem::Version
471
503
  version: '0'
472
504
  requirements: []
473
- rubygems_version: 3.1.4
505
+ rubygems_version: 3.2.24
474
506
  signing_key:
475
507
  specification_version: 4
476
508
  summary: Instructure-maintained fork of delayed_job
477
509
  test_files:
478
510
  - spec/sample_jobs.rb
479
511
  - spec/spec_helper.rb
480
- - spec/redis_job_spec.rb
512
+ - spec/gemfiles/60.gemfile.lock
513
+ - spec/gemfiles/61.gemfile
481
514
  - spec/gemfiles/60.gemfile
482
- - spec/gemfiles/42.gemfile
483
515
  - spec/gemfiles/52.gemfile
484
- - spec/gemfiles/50.gemfile
485
- - spec/gemfiles/51.gemfile
516
+ - spec/gemfiles/52.gemfile.lock
486
517
  - spec/shared_jobs_specs.rb
487
518
  - spec/shared/performable_method.rb
488
519
  - spec/shared/testing.rb
@@ -1,50 +0,0 @@
1
- local action, id_string, flavor, query, now = unpack(ARGV)
2
-
3
- local ids = {}
4
-
5
- if string.len(flavor) > 0 then
6
- if flavor == 'current' then
7
- ids = redis.call('ZRANGE', Keys.queue(query), 0, -1)
8
- elseif flavor == 'future' then
9
- ids = redis.call('ZRANGE', Keys.future_queue(query), 0, -1)
10
- elseif flavor == 'strand' then
11
- ids = redis.call('LRANGE', Keys.strand(query), 0, -1)
12
- elseif flavor == 'tag' then
13
- ids = redis.call('SMEMBERS', Keys.tag(query))
14
- end
15
- else
16
- -- can't pass an array to redis/lua, so we split the string here
17
- for id in string.gmatch(id_string, "([%w-]+)") do
18
- if job_exists(id) then
19
- table.insert(ids, id)
20
- end
21
- end
22
- end
23
-
24
- local count = 0
25
- for idx, job_id in ipairs(ids) do
26
- if action == 'hold' then
27
- local queue, strand, locked_by = unpack(redis.call('HMGET', Keys.job(job_id), 'queue', 'strand', 'locked_by'))
28
- if not locked_by then
29
- count = count + 1
30
- remove_from_queues(job_id, queue, strand)
31
- redis.call('HMSET', Keys.job(job_id), 'locked_at', now, 'locked_by', 'on hold', 'attempts', 50)
32
- end
33
- elseif action == 'unhold' then
34
- local queue, locked_by = unpack(redis.call('HMGET', Keys.job(job_id), 'queue', 'locked_by'))
35
- if locked_by == 'on hold' then
36
- count = count + 1
37
- add_to_queues(job_id, queue, now)
38
- redis.call('HDEL', Keys.job(job_id), 'locked_at', 'locked_by')
39
- redis.call('HMSET', Keys.job(job_id), 'attempts', 0)
40
- end
41
- elseif action == 'destroy' then
42
- local locked_by = redis.call('HGET', Keys.job(job_id), 'locked_by')
43
- if not locked_by or locked_by == 'on hold' then
44
- count = count + 1
45
- destroy_job(job_id, now)
46
- end
47
- end
48
- end
49
-
50
- return count
@@ -1,2 +0,0 @@
1
- local job_id, now = unpack(ARGV)
2
- destroy_job(job_id, now)
@@ -1,29 +0,0 @@
1
- local job_id, queue, strand, now, for_singleton = unpack(ARGV)
2
- local strand_key = Keys.strand(strand)
3
-
4
- -- if this is a singleton job, only queue it up if another doesn't exist on the strand
5
- -- otherwise, delete it and return the other job id
6
- if for_singleton then
7
- local job_ids = redis.call('LRANGE', strand_key, 0, 1)
8
- local job_to_check = 1
9
- if job_exists(job_ids[1]) and redis.call('HGET', Keys.job(job_ids[1]), 'locked_at') then
10
- job_to_check = 2
11
- end
12
-
13
- local job_to_check_id = job_ids[job_to_check]
14
- if job_exists(job_to_check_id) then
15
- -- delete the new job, we found a match
16
- redis.call('DEL', Keys.job(job_id))
17
- return job_to_check_id
18
- end
19
- end
20
-
21
- -- if this job is in a strand, add it to the strand queue first
22
- -- if it's not at the front of the strand, we won't enqueue it below
23
- if strand_key then
24
- add_to_strand(job_id, strand)
25
- end
26
-
27
- add_to_queues(job_id, queue, now)
28
-
29
- return job_id
@@ -1,5 +0,0 @@
1
- local job_id = unpack(ARGV)
2
- local failed_at, queue, strand = unpack(redis.call('HMGET', Keys.job(job_id), 'failed_at', 'queue', 'strand'))
3
-
4
- remove_from_queues(job_id, queue, strand)
5
- redis.call('ZADD', Keys.failed_jobs(), failed_at, job_id)
@@ -1,3 +0,0 @@
1
- local queue, limit, offset, min_priority, max_priority, now = unpack(ARGV)
2
-
3
- return find_available(queue, limit, offset, min_priority, max_priority, now)
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'redis/scripting'
4
-
5
- # This module handles loading the Lua functions into Redis and running them
6
- module Delayed::Backend::Redis
7
- class Functions < ::Redis::Scripting::Module
8
- def initialize(redis)
9
- super(redis, File.dirname(__FILE__))
10
- end
11
-
12
- def run_script(script, keys, argv)
13
- result = nil
14
- ms = Benchmark.ms { result = super }
15
- line = 'Redis Jobs Timing: %s (%.1fms)' % [script.name, ms]
16
- ActiveRecord::Base.logger.debug(line)
17
- result
18
- end
19
-
20
- def find_available(queue, limit, offset, min_priority, max_priority, now)
21
- run(:find_available, [], [queue, limit, offset, min_priority, max_priority, now.utc.to_f])
22
- end
23
-
24
- def get_and_lock_next_available(worker_name, queue, min_priority, max_priority, now)
25
- attrs = run(:get_and_lock_next_available, [], [queue, min_priority, max_priority, worker_name, now.utc.to_f])
26
- Hash[*attrs]
27
- end
28
-
29
- def enqueue(job_id, queue, strand, now)
30
- run(:enqueue, [], [job_id, queue, strand, now.utc.to_f])
31
- end
32
-
33
- def create_singleton(job_id, queue, strand, now)
34
- run(:enqueue, [], [job_id, queue, strand, now.utc.to_f, true])
35
- end
36
-
37
- def destroy_job(job_id, now)
38
- run(:destroy_job, [], [job_id, now.utc.to_f])
39
- end
40
-
41
- def tickle_strand(job_id, strand, now)
42
- run(:tickle_strand, [], [job_id, strand, now.utc.to_f])
43
- end
44
-
45
- def fail_job(job_id)
46
- run(:fail_job, [], [job_id])
47
- end
48
-
49
- def set_running(job_id)
50
- run(:set_running, [], [job_id])
51
- end
52
-
53
- def bulk_update(action, ids, flavor, query, now)
54
- ids = (ids || []).join(",")
55
- run(:bulk_update, [], [action, ids, flavor, query, now.utc.to_f])
56
- end
57
-
58
- end
59
- end
@@ -1,17 +0,0 @@
1
- local queue, min_priority, max_priority, worker_name, now = unpack(ARGV)
2
- local job_id = find_available(queue, 1, 0, min_priority, max_priority, now)[1]
3
-
4
- if job_exists(job_id) then
5
- -- update the job with locked_by and locked_at
6
- redis.call('HMSET', Keys.job(job_id), 'locked_by', worker_name, 'locked_at', now)
7
-
8
- -- add the job to the running_jobs set
9
- redis.call('ZADD', Keys.running_jobs(), now, job_id)
10
- -- remove the job from the pending jobs queue
11
- redis.call('ZREM', Keys.queue(queue), job_id)
12
-
13
- -- return the list of job attributes
14
- return redis.call('HGETALL', Keys.job(job_id))
15
- else
16
- return {}
17
- end