inst-jobs 2.3.1 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/db/migrate/20101216224513_create_delayed_jobs.rb +9 -7
- data/db/migrate/20110531144916_cleanup_delayed_jobs_indexes.rb +8 -13
- data/db/migrate/20110610213249_optimize_delayed_jobs.rb +8 -8
- data/db/migrate/20110831210257_add_delayed_jobs_next_in_strand.rb +25 -25
- data/db/migrate/20120510004759_delayed_jobs_delete_trigger_lock_for_update.rb +4 -8
- data/db/migrate/20120531150712_drop_psql_jobs_pop_fn.rb +1 -3
- data/db/migrate/20120607164022_delayed_jobs_use_advisory_locks.rb +11 -15
- data/db/migrate/20120607181141_index_jobs_on_locked_by.rb +1 -1
- data/db/migrate/20120608191051_add_jobs_run_at_index.rb +2 -2
- data/db/migrate/20120927184213_change_delayed_jobs_handler_to_text.rb +1 -1
- data/db/migrate/20140505215510_copy_failed_jobs_original_id.rb +2 -3
- data/db/migrate/20150807133223_add_max_concurrent_to_jobs.rb +9 -13
- data/db/migrate/20151210162949_improve_max_concurrent.rb +4 -8
- data/db/migrate/20161206323555_add_back_default_string_limits_jobs.rb +3 -2
- data/db/migrate/20181217155351_speed_up_max_concurrent_triggers.rb +13 -17
- data/db/migrate/20200330230722_add_id_to_get_delayed_jobs_index.rb +8 -8
- data/db/migrate/20200824222232_speed_up_max_concurrent_delete_trigger.rb +72 -77
- data/db/migrate/20200825011002_add_strand_order_override.rb +93 -97
- data/db/migrate/20210809145804_add_n_strand_index.rb +12 -0
- data/db/migrate/20210812210128_add_singleton_column.rb +203 -0
- data/exe/inst_jobs +3 -2
- data/lib/delayed/backend/active_record.rb +182 -148
- data/lib/delayed/backend/base.rb +80 -69
- data/lib/delayed/batch.rb +11 -9
- data/lib/delayed/cli.rb +98 -84
- data/lib/delayed/core_ext/kernel.rb +4 -2
- data/lib/delayed/daemon.rb +70 -74
- data/lib/delayed/job_tracking.rb +26 -25
- data/lib/delayed/lifecycle.rb +27 -24
- data/lib/delayed/log_tailer.rb +17 -17
- data/lib/delayed/logging.rb +13 -16
- data/lib/delayed/message_sending.rb +42 -51
- data/lib/delayed/performable_method.rb +5 -7
- data/lib/delayed/periodic.rb +66 -65
- data/lib/delayed/plugin.rb +2 -4
- data/lib/delayed/pool.rb +198 -192
- data/lib/delayed/server/helpers.rb +6 -6
- data/lib/delayed/server.rb +51 -54
- data/lib/delayed/settings.rb +93 -81
- data/lib/delayed/testing.rb +21 -22
- data/lib/delayed/version.rb +1 -1
- data/lib/delayed/work_queue/in_process.rb +21 -17
- data/lib/delayed/work_queue/parent_process/client.rb +55 -53
- data/lib/delayed/work_queue/parent_process/server.rb +215 -209
- data/lib/delayed/work_queue/parent_process.rb +52 -53
- data/lib/delayed/worker/consul_health_check.rb +21 -19
- data/lib/delayed/worker/health_check.rb +21 -12
- data/lib/delayed/worker/null_health_check.rb +3 -1
- data/lib/delayed/worker/process_helper.rb +8 -9
- data/lib/delayed/worker.rb +271 -261
- data/lib/delayed/yaml_extensions.rb +12 -10
- data/lib/delayed_job.rb +37 -38
- data/lib/inst-jobs.rb +1 -1
- data/spec/active_record_job_spec.rb +128 -135
- data/spec/delayed/cli_spec.rb +7 -7
- data/spec/delayed/daemon_spec.rb +8 -8
- data/spec/delayed/message_sending_spec.rb +8 -9
- data/spec/delayed/periodic_spec.rb +13 -12
- data/spec/delayed/server_spec.rb +38 -38
- data/spec/delayed/settings_spec.rb +26 -25
- data/spec/delayed/work_queue/in_process_spec.rb +7 -7
- data/spec/delayed/work_queue/parent_process/client_spec.rb +16 -12
- data/spec/delayed/work_queue/parent_process/server_spec.rb +43 -40
- data/spec/delayed/work_queue/parent_process_spec.rb +21 -21
- data/spec/delayed/worker/consul_health_check_spec.rb +22 -22
- data/spec/delayed/worker/health_check_spec.rb +51 -49
- data/spec/delayed/worker_spec.rb +28 -25
- data/spec/gemfiles/52.gemfile +5 -3
- data/spec/gemfiles/52.gemfile.lock +240 -0
- data/spec/gemfiles/60.gemfile +5 -3
- data/spec/gemfiles/60.gemfile.lock +246 -0
- data/spec/gemfiles/61.gemfile +5 -3
- data/spec/sample_jobs.rb +45 -15
- data/spec/shared/delayed_batch.rb +74 -67
- data/spec/shared/delayed_method.rb +143 -102
- data/spec/shared/performable_method.rb +39 -38
- data/spec/shared/shared_backend.rb +537 -437
- data/spec/shared/testing.rb +14 -14
- data/spec/shared/worker.rb +155 -147
- data/spec/shared_jobs_specs.rb +13 -13
- data/spec/spec_helper.rb +43 -40
- metadata +73 -52
- data/lib/delayed/backend/redis/bulk_update.lua +0 -50
- data/lib/delayed/backend/redis/destroy_job.lua +0 -2
- data/lib/delayed/backend/redis/enqueue.lua +0 -29
- data/lib/delayed/backend/redis/fail_job.lua +0 -5
- data/lib/delayed/backend/redis/find_available.lua +0 -3
- data/lib/delayed/backend/redis/functions.rb +0 -59
- data/lib/delayed/backend/redis/get_and_lock_next_available.lua +0 -17
- data/lib/delayed/backend/redis/includes/jobs_common.lua +0 -203
- data/lib/delayed/backend/redis/job.rb +0 -528
- data/lib/delayed/backend/redis/set_running.lua +0 -5
- data/lib/delayed/backend/redis/tickle_strand.lua +0 -2
- data/spec/redis_job_spec.rb +0 -148
data/spec/shared_jobs_specs.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
require_relative "shared/delayed_batch"
|
4
|
+
require_relative "shared/delayed_method"
|
5
|
+
require_relative "shared/performable_method"
|
6
|
+
require_relative "shared/shared_backend"
|
7
|
+
require_relative "shared/testing"
|
8
|
+
require_relative "shared/worker"
|
9
9
|
|
10
|
-
shared_examples_for
|
11
|
-
include_examples
|
12
|
-
include_examples
|
13
|
-
include_examples
|
14
|
-
include_examples
|
15
|
-
include_examples
|
16
|
-
include_examples
|
10
|
+
shared_examples_for "a delayed_jobs implementation" do
|
11
|
+
include_examples "a backend"
|
12
|
+
include_examples "Delayed::Batch"
|
13
|
+
include_examples "random ruby objects"
|
14
|
+
include_examples "Delayed::PerformableMethod"
|
15
|
+
include_examples "Delayed::Worker"
|
16
|
+
include_examples "Delayed::Testing"
|
17
17
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "delayed_job"
|
4
|
+
require "delayed/testing"
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
6
|
+
require "database_cleaner"
|
7
|
+
require "rack/test"
|
8
|
+
require "timecop"
|
9
|
+
require "webmock/rspec"
|
10
10
|
|
11
|
-
require
|
12
|
-
require
|
11
|
+
require "pry"
|
12
|
+
require "byebug"
|
13
13
|
|
14
14
|
RSpec.configure do |config|
|
15
|
-
|
16
15
|
config.expect_with(:rspec) do |c|
|
17
|
-
c.syntax = [
|
16
|
+
c.syntax = %i[should expect]
|
18
17
|
end
|
19
18
|
|
20
19
|
config.before(:suite) do
|
@@ -23,47 +22,42 @@ RSpec.configure do |config|
|
|
23
22
|
WebMock.disable_net_connect!
|
24
23
|
end
|
25
24
|
|
26
|
-
config.before
|
27
|
-
if
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
config.before do |example|
|
26
|
+
DatabaseCleaner.strategy = if example.metadata[:sinatra] || example.metadata[:non_transactional]
|
27
|
+
:truncation
|
28
|
+
else
|
29
|
+
:transaction
|
30
|
+
end
|
32
31
|
DatabaseCleaner.start
|
33
32
|
end
|
34
33
|
|
35
|
-
config.after
|
34
|
+
config.after do
|
36
35
|
DatabaseCleaner.clean
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
40
39
|
module NoYamlDump
|
41
|
-
def encode_with(coder)
|
42
|
-
end
|
40
|
+
def encode_with(coder); end
|
43
41
|
end
|
44
42
|
# example groups are often the sender, and if we try to serialize them,
|
45
43
|
# the resultant object is then encoded in the sender, and then we serialize
|
46
44
|
# again, and it just keeps getting bigger and bigger and bigger...
|
47
45
|
RSpec::Core::ExampleGroup.include(NoYamlDump)
|
48
46
|
|
49
|
-
ENV[
|
50
|
-
ENV[
|
51
|
-
ENV[
|
52
|
-
ENV['TEST_REDIS_CONNECTION'] ||= 'redis://localhost:6379/'
|
53
|
-
|
54
|
-
Delayed::Backend::Redis::Job.redis = Redis.new(url: ENV['TEST_REDIS_CONNECTION'])
|
55
|
-
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']}"
|
56
50
|
|
57
51
|
connection_config = {
|
58
52
|
adapter: :postgresql,
|
59
|
-
host: ENV[
|
60
|
-
encoding:
|
61
|
-
username: ENV[
|
62
|
-
database: ENV[
|
53
|
+
host: ENV["TEST_DB_HOST"].presence,
|
54
|
+
encoding: "utf8",
|
55
|
+
username: ENV["TEST_DB_USERNAME"],
|
56
|
+
database: ENV["TEST_DB_DATABASE"]
|
63
57
|
}
|
64
58
|
|
65
59
|
def migrate(file)
|
66
|
-
if ::Rails.version >=
|
60
|
+
if ::Rails.version >= "6"
|
67
61
|
ActiveRecord::MigrationContext.new(file, ActiveRecord::SchemaMigration).migrate
|
68
62
|
else
|
69
63
|
ActiveRecord::MigrationContext.new(file).migrate
|
@@ -71,27 +65,36 @@ def migrate(file)
|
|
71
65
|
end
|
72
66
|
|
73
67
|
# create the test db if it does not exist, to help out wwtd
|
74
|
-
ActiveRecord::Base.establish_connection(connection_config.merge(database:
|
68
|
+
ActiveRecord::Base.establish_connection(connection_config.merge(database: "postgres"))
|
75
69
|
begin
|
76
70
|
ActiveRecord::Base.connection.create_database(connection_config[:database])
|
77
71
|
rescue ActiveRecord::StatementInvalid
|
72
|
+
nil
|
78
73
|
end
|
79
74
|
ActiveRecord::Base.establish_connection(connection_config)
|
80
|
-
# TODO reset db and migrate again, to test migrations
|
75
|
+
# TODO: reset db and migrate again, to test migrations
|
81
76
|
|
82
77
|
migrate("db/migrate")
|
83
78
|
migrate("spec/migrate")
|
84
79
|
Delayed::Backend::ActiveRecord::Job.reset_column_information
|
85
80
|
Delayed::Backend::ActiveRecord::Job::Failed.reset_column_information
|
86
81
|
|
87
|
-
Time.zone =
|
82
|
+
Time.zone = "UTC" # rubocop:disable Rails/TimeZoneAssignment
|
88
83
|
Rails.logger = Logger.new(nil)
|
89
84
|
|
90
85
|
# Purely useful for test cases...
|
91
86
|
class Story < ActiveRecord::Base
|
92
|
-
def tell
|
93
|
-
|
94
|
-
|
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
|
95
98
|
|
96
99
|
handle_asynchronously :whatever
|
97
100
|
handle_asynchronously :whatever_else, queue: "testqueue"
|
@@ -114,7 +117,7 @@ module MyReverser
|
|
114
117
|
end
|
115
118
|
|
116
119
|
def change_setting(klass, setting_name, value)
|
117
|
-
old_val = klass.
|
120
|
+
old_val = klass.send(setting_name)
|
118
121
|
klass.send("#{setting_name}=", value)
|
119
122
|
yield
|
120
123
|
ensure
|
@@ -125,5 +128,5 @@ def run_job(job)
|
|
125
128
|
Delayed::Testing.run_job(job)
|
126
129
|
end
|
127
130
|
|
128
|
-
|
129
|
-
|
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.
|
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-
|
12
|
+
date: 2021-09-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -60,47 +60,19 @@ dependencies:
|
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '3'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '5.2'
|
69
|
-
type: :runtime
|
70
|
-
prerelease: false
|
71
|
-
version_requirements: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '5.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
|
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
|
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:
|
91
|
+
name: railties
|
120
92
|
requirement: !ruby/object:Gem::Requirement
|
121
93
|
requirements:
|
122
|
-
- - "
|
94
|
+
- - ">="
|
123
95
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
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: '
|
103
|
+
version: '5.2'
|
132
104
|
- !ruby/object:Gem::Dependency
|
133
105
|
name: bump
|
134
106
|
requirement: !ruby/object:Gem::Requirement
|
@@ -283,6 +255,62 @@ dependencies:
|
|
283
255
|
- - "~>"
|
284
256
|
- !ruby/object:Gem::Version
|
285
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'
|
307
|
+
type: :development
|
308
|
+
prerelease: false
|
309
|
+
version_requirements: !ruby/object:Gem::Requirement
|
310
|
+
requirements:
|
311
|
+
- - "~>"
|
312
|
+
- !ruby/object:Gem::Version
|
313
|
+
version: '2.4'
|
286
314
|
- !ruby/object:Gem::Dependency
|
287
315
|
name: sinatra
|
288
316
|
requirement: !ruby/object:Gem::Requirement
|
@@ -387,20 +415,11 @@ files:
|
|
387
415
|
- db/migrate/20200330230722_add_id_to_get_delayed_jobs_index.rb
|
388
416
|
- db/migrate/20200824222232_speed_up_max_concurrent_delete_trigger.rb
|
389
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
|
390
420
|
- exe/inst_jobs
|
391
421
|
- lib/delayed/backend/active_record.rb
|
392
422
|
- lib/delayed/backend/base.rb
|
393
|
-
- lib/delayed/backend/redis/bulk_update.lua
|
394
|
-
- lib/delayed/backend/redis/destroy_job.lua
|
395
|
-
- lib/delayed/backend/redis/enqueue.lua
|
396
|
-
- lib/delayed/backend/redis/fail_job.lua
|
397
|
-
- lib/delayed/backend/redis/find_available.lua
|
398
|
-
- lib/delayed/backend/redis/functions.rb
|
399
|
-
- lib/delayed/backend/redis/get_and_lock_next_available.lua
|
400
|
-
- lib/delayed/backend/redis/includes/jobs_common.lua
|
401
|
-
- lib/delayed/backend/redis/job.rb
|
402
|
-
- lib/delayed/backend/redis/set_running.lua
|
403
|
-
- lib/delayed/backend/redis/tickle_strand.lua
|
404
423
|
- lib/delayed/batch.rb
|
405
424
|
- lib/delayed/cli.rb
|
406
425
|
- lib/delayed/core_ext/kernel.rb
|
@@ -451,10 +470,11 @@ files:
|
|
451
470
|
- spec/delayed/worker/health_check_spec.rb
|
452
471
|
- spec/delayed/worker_spec.rb
|
453
472
|
- spec/gemfiles/52.gemfile
|
473
|
+
- spec/gemfiles/52.gemfile.lock
|
454
474
|
- spec/gemfiles/60.gemfile
|
475
|
+
- spec/gemfiles/60.gemfile.lock
|
455
476
|
- spec/gemfiles/61.gemfile
|
456
477
|
- spec/migrate/20140924140513_add_story_table.rb
|
457
|
-
- spec/redis_job_spec.rb
|
458
478
|
- spec/sample_jobs.rb
|
459
479
|
- spec/shared/delayed_batch.rb
|
460
480
|
- spec/shared/delayed_method.rb
|
@@ -482,17 +502,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
482
502
|
- !ruby/object:Gem::Version
|
483
503
|
version: '0'
|
484
504
|
requirements: []
|
485
|
-
rubygems_version: 3.2.
|
505
|
+
rubygems_version: 3.2.24
|
486
506
|
signing_key:
|
487
507
|
specification_version: 4
|
488
508
|
summary: Instructure-maintained fork of delayed_job
|
489
509
|
test_files:
|
490
510
|
- spec/sample_jobs.rb
|
491
511
|
- spec/spec_helper.rb
|
492
|
-
- spec/
|
512
|
+
- spec/gemfiles/60.gemfile.lock
|
493
513
|
- spec/gemfiles/61.gemfile
|
494
514
|
- spec/gemfiles/60.gemfile
|
495
515
|
- spec/gemfiles/52.gemfile
|
516
|
+
- spec/gemfiles/52.gemfile.lock
|
496
517
|
- spec/shared_jobs_specs.rb
|
497
518
|
- spec/shared/performable_method.rb
|
498
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
|