inst-jobs 2.3.3 → 2.4.3
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 +3 -3
- data/db/migrate/20210812210128_add_singleton_column.rb +200 -0
- data/exe/inst_jobs +3 -2
- data/lib/delayed/backend/active_record.rb +183 -149
- data/lib/delayed/backend/base.rb +80 -75
- 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 +43 -52
- data/lib/delayed/performable_method.rb +6 -8
- data/lib/delayed/periodic.rb +66 -65
- data/lib/delayed/plugin.rb +2 -4
- data/lib/delayed/pool.rb +198 -193
- 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 -18
- data/lib/delayed/work_queue/parent_process/client.rb +54 -55
- 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 -265
- 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 +129 -136
- data/spec/delayed/cli_spec.rb +7 -7
- data/spec/delayed/daemon_spec.rb +8 -8
- data/spec/delayed/message_sending_spec.rb +16 -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 +15 -11
- 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/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 +534 -441
- 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 +81 -59
- 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/gemfiles/52.gemfile +0 -7
- data/spec/gemfiles/60.gemfile +0 -7
- data/spec/gemfiles/60.gemfile.lock +0 -246
- data/spec/gemfiles/61.gemfile +0 -7
- data/spec/redis_job_spec.rb +0 -148
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,15 +1,15 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Luetke
|
8
8
|
- Brian Palmer
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-09-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -60,75 +60,61 @@ 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
|
63
|
+
name: debug_inspector
|
78
64
|
requirement: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
|
-
- - "
|
66
|
+
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
68
|
+
version: '1.0'
|
83
69
|
type: :runtime
|
84
70
|
prerelease: false
|
85
71
|
version_requirements: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
|
-
- - "
|
73
|
+
- - "~>"
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
75
|
+
version: '1.0'
|
90
76
|
- !ruby/object:Gem::Dependency
|
91
|
-
name:
|
77
|
+
name: fugit
|
92
78
|
requirement: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
80
|
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.
|
82
|
+
version: '1.3'
|
97
83
|
type: :runtime
|
98
84
|
prerelease: false
|
99
85
|
version_requirements: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
87
|
- - "~>"
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.
|
89
|
+
version: '1.3'
|
104
90
|
- !ruby/object:Gem::Dependency
|
105
|
-
name:
|
91
|
+
name: railties
|
106
92
|
requirement: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
|
-
- - "
|
94
|
+
- - ">="
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
96
|
+
version: '5.2'
|
111
97
|
type: :runtime
|
112
98
|
prerelease: false
|
113
99
|
version_requirements: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
|
-
- - "
|
101
|
+
- - ">="
|
116
102
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
103
|
+
version: '5.2'
|
118
104
|
- !ruby/object:Gem::Dependency
|
119
|
-
name:
|
105
|
+
name: appraisal
|
120
106
|
requirement: !ruby/object:Gem::Requirement
|
121
107
|
requirements:
|
122
108
|
- - "~>"
|
123
109
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
125
|
-
type: :
|
110
|
+
version: '2.4'
|
111
|
+
type: :development
|
126
112
|
prerelease: false
|
127
113
|
version_requirements: !ruby/object:Gem::Requirement
|
128
114
|
requirements:
|
129
115
|
- - "~>"
|
130
116
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
117
|
+
version: '2.4'
|
132
118
|
- !ruby/object:Gem::Dependency
|
133
119
|
name: bump
|
134
120
|
requirement: !ruby/object:Gem::Requirement
|
@@ -283,6 +269,62 @@ dependencies:
|
|
283
269
|
- - "~>"
|
284
270
|
- !ruby/object:Gem::Version
|
285
271
|
version: '3.10'
|
272
|
+
- !ruby/object:Gem::Dependency
|
273
|
+
name: rubocop
|
274
|
+
requirement: !ruby/object:Gem::Requirement
|
275
|
+
requirements:
|
276
|
+
- - "~>"
|
277
|
+
- !ruby/object:Gem::Version
|
278
|
+
version: '1.19'
|
279
|
+
type: :development
|
280
|
+
prerelease: false
|
281
|
+
version_requirements: !ruby/object:Gem::Requirement
|
282
|
+
requirements:
|
283
|
+
- - "~>"
|
284
|
+
- !ruby/object:Gem::Version
|
285
|
+
version: '1.19'
|
286
|
+
- !ruby/object:Gem::Dependency
|
287
|
+
name: rubocop-rails
|
288
|
+
requirement: !ruby/object:Gem::Requirement
|
289
|
+
requirements:
|
290
|
+
- - "~>"
|
291
|
+
- !ruby/object:Gem::Version
|
292
|
+
version: '2.11'
|
293
|
+
type: :development
|
294
|
+
prerelease: false
|
295
|
+
version_requirements: !ruby/object:Gem::Requirement
|
296
|
+
requirements:
|
297
|
+
- - "~>"
|
298
|
+
- !ruby/object:Gem::Version
|
299
|
+
version: '2.11'
|
300
|
+
- !ruby/object:Gem::Dependency
|
301
|
+
name: rubocop-rake
|
302
|
+
requirement: !ruby/object:Gem::Requirement
|
303
|
+
requirements:
|
304
|
+
- - "~>"
|
305
|
+
- !ruby/object:Gem::Version
|
306
|
+
version: '0.6'
|
307
|
+
type: :development
|
308
|
+
prerelease: false
|
309
|
+
version_requirements: !ruby/object:Gem::Requirement
|
310
|
+
requirements:
|
311
|
+
- - "~>"
|
312
|
+
- !ruby/object:Gem::Version
|
313
|
+
version: '0.6'
|
314
|
+
- !ruby/object:Gem::Dependency
|
315
|
+
name: rubocop-rspec
|
316
|
+
requirement: !ruby/object:Gem::Requirement
|
317
|
+
requirements:
|
318
|
+
- - "~>"
|
319
|
+
- !ruby/object:Gem::Version
|
320
|
+
version: '2.4'
|
321
|
+
type: :development
|
322
|
+
prerelease: false
|
323
|
+
version_requirements: !ruby/object:Gem::Requirement
|
324
|
+
requirements:
|
325
|
+
- - "~>"
|
326
|
+
- !ruby/object:Gem::Version
|
327
|
+
version: '2.4'
|
286
328
|
- !ruby/object:Gem::Dependency
|
287
329
|
name: sinatra
|
288
330
|
requirement: !ruby/object:Gem::Requirement
|
@@ -353,7 +395,7 @@ dependencies:
|
|
353
395
|
- - "~>"
|
354
396
|
- !ruby/object:Gem::Version
|
355
397
|
version: 1.4.0
|
356
|
-
description:
|
398
|
+
description:
|
357
399
|
email:
|
358
400
|
- brianp@instructure.com
|
359
401
|
executables:
|
@@ -388,20 +430,10 @@ files:
|
|
388
430
|
- db/migrate/20200824222232_speed_up_max_concurrent_delete_trigger.rb
|
389
431
|
- db/migrate/20200825011002_add_strand_order_override.rb
|
390
432
|
- db/migrate/20210809145804_add_n_strand_index.rb
|
433
|
+
- db/migrate/20210812210128_add_singleton_column.rb
|
391
434
|
- exe/inst_jobs
|
392
435
|
- lib/delayed/backend/active_record.rb
|
393
436
|
- lib/delayed/backend/base.rb
|
394
|
-
- lib/delayed/backend/redis/bulk_update.lua
|
395
|
-
- lib/delayed/backend/redis/destroy_job.lua
|
396
|
-
- lib/delayed/backend/redis/enqueue.lua
|
397
|
-
- lib/delayed/backend/redis/fail_job.lua
|
398
|
-
- lib/delayed/backend/redis/find_available.lua
|
399
|
-
- lib/delayed/backend/redis/functions.rb
|
400
|
-
- lib/delayed/backend/redis/get_and_lock_next_available.lua
|
401
|
-
- lib/delayed/backend/redis/includes/jobs_common.lua
|
402
|
-
- lib/delayed/backend/redis/job.rb
|
403
|
-
- lib/delayed/backend/redis/set_running.lua
|
404
|
-
- lib/delayed/backend/redis/tickle_strand.lua
|
405
437
|
- lib/delayed/batch.rb
|
406
438
|
- lib/delayed/cli.rb
|
407
439
|
- lib/delayed/core_ext/kernel.rb
|
@@ -451,12 +483,7 @@ files:
|
|
451
483
|
- spec/delayed/worker/consul_health_check_spec.rb
|
452
484
|
- spec/delayed/worker/health_check_spec.rb
|
453
485
|
- spec/delayed/worker_spec.rb
|
454
|
-
- spec/gemfiles/52.gemfile
|
455
|
-
- spec/gemfiles/60.gemfile
|
456
|
-
- spec/gemfiles/60.gemfile.lock
|
457
|
-
- spec/gemfiles/61.gemfile
|
458
486
|
- spec/migrate/20140924140513_add_story_table.rb
|
459
|
-
- spec/redis_job_spec.rb
|
460
487
|
- spec/sample_jobs.rb
|
461
488
|
- spec/shared/delayed_batch.rb
|
462
489
|
- spec/shared/delayed_method.rb
|
@@ -469,7 +496,7 @@ files:
|
|
469
496
|
homepage: https://github.com/instructure/inst-jobs
|
470
497
|
licenses: []
|
471
498
|
metadata: {}
|
472
|
-
post_install_message:
|
499
|
+
post_install_message:
|
473
500
|
rdoc_options: []
|
474
501
|
require_paths:
|
475
502
|
- lib
|
@@ -484,18 +511,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
484
511
|
- !ruby/object:Gem::Version
|
485
512
|
version: '0'
|
486
513
|
requirements: []
|
487
|
-
rubygems_version: 3.
|
488
|
-
signing_key:
|
514
|
+
rubygems_version: 3.2.16
|
515
|
+
signing_key:
|
489
516
|
specification_version: 4
|
490
517
|
summary: Instructure-maintained fork of delayed_job
|
491
518
|
test_files:
|
492
519
|
- spec/sample_jobs.rb
|
493
520
|
- spec/spec_helper.rb
|
494
|
-
- spec/redis_job_spec.rb
|
495
|
-
- spec/gemfiles/60.gemfile.lock
|
496
|
-
- spec/gemfiles/61.gemfile
|
497
|
-
- spec/gemfiles/60.gemfile
|
498
|
-
- spec/gemfiles/52.gemfile
|
499
521
|
- spec/shared_jobs_specs.rb
|
500
522
|
- spec/shared/performable_method.rb
|
501
523
|
- 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,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,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
|