backburner-allq 1.0.48 → 1.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/deploy.sh +1 -1
- data/lib/backburner/version.rb +1 -1
- data/test/allq/back_burner_test.rb +2 -24
- data/test/allq/worker_test.rb +0 -1
- data/test/test_helper.rb +2 -0
- data/test/worker_test.rb +72 -69
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fc3dc2099e7b4b5a1d52311ac2fcbb352362847112bcc6e0901a58fa176f4d7
|
4
|
+
data.tar.gz: 835f732ea43c72ca825f319f9e6c0aecf3132cda7759adfa15467e5299cb0282
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90267229af350ccfa39a5087d99b5065713c698ecd9bb2523d8441350542c4bc9be2e956e6b4a9e6197bf99da50e3b62b503132fa94b19416d896c8c494445ce
|
7
|
+
data.tar.gz: c2d65d3726e881243c9ce878bef1813e2664c43960ac2cdf8b8803dba0b26212e90dc699fa35a11ea082d2fac8125f01a57165f253c06a96389c8fef69b61db1
|
data/deploy.sh
CHANGED
data/lib/backburner/version.rb
CHANGED
@@ -13,7 +13,8 @@ class TestBackburnerJob
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
class TestWorker < Backburner::Worker
|
16
|
+
class TestWorker < Backburner::Worker
|
17
|
+
end
|
17
18
|
|
18
19
|
describe 'Backburner module' do
|
19
20
|
before do
|
@@ -21,29 +22,6 @@ describe 'Backburner module' do
|
|
21
22
|
clear_jobs!(Backburner.configuration.primary_queue, 'test-plain', 'parent-plain', 'bar.baz.foo')
|
22
23
|
end
|
23
24
|
|
24
|
-
describe 'for work method' do
|
25
|
-
it 'invokes worker simple start' do
|
26
|
-
Backburner::Workers::Simple.expects(:start).with(%w[foo bar])
|
27
|
-
Backburner.work('foo', 'bar')
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'invokes other worker if specified in configuration' do
|
31
|
-
Backburner.configure { |config| config.default_worker = TestWorker }
|
32
|
-
TestWorker.expects(:start).with(%w[foo bar])
|
33
|
-
Backburner.work('foo', 'bar')
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'invokes other worker if specified in work method as options' do
|
37
|
-
TestWorker.expects(:start).with(%w[foo bar])
|
38
|
-
Backburner.work('foo', 'bar', worker: TestWorker)
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'invokes worker start with no args' do
|
42
|
-
Backburner::Workers::Simple.expects(:start).with([])
|
43
|
-
Backburner.work
|
44
|
-
end
|
45
|
-
end # work!
|
46
|
-
|
47
25
|
describe 'for configuration' do
|
48
26
|
it 'remembers the tube_namespace' do
|
49
27
|
assert_equal 'demo.test', Backburner.configuration.tube_namespace
|
data/test/allq/worker_test.rb
CHANGED
@@ -65,7 +65,6 @@ describe 'Backburner::Worker module' do
|
|
65
65
|
worker = Backburner::Workers::Simple.new('demo.test.parent-plain')
|
66
66
|
worker.prepare
|
67
67
|
|
68
|
-
TestParentJob.expects(:perform_with_task)
|
69
68
|
job = worker.work_one_job(allq_connection, 'demo.test.parent-plain')
|
70
69
|
assert_equal job.special, "true"
|
71
70
|
end
|
data/test/test_helper.rb
CHANGED
data/test/worker_test.rb
CHANGED
@@ -1,136 +1,139 @@
|
|
1
|
-
require File.expand_path('
|
1
|
+
require File.expand_path('test_helper', __dir__)
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe 'Backburner::Worker module' do
|
4
4
|
before do
|
5
5
|
Backburner.default_queues.clear
|
6
|
-
clear_jobs!(Backburner.configuration.primary_queue,
|
6
|
+
clear_jobs!(Backburner.configuration.primary_queue, 'test-plain', 'test.bar', 'bar.baz.foo')
|
7
7
|
end
|
8
8
|
|
9
|
-
describe
|
10
|
-
it
|
11
|
-
Backburner::Worker.enqueue TestPlainJob, [7, 9], :
|
12
|
-
pop_one_job(
|
13
|
-
assert_equal
|
14
|
-
assert_equal [7, 9], body[
|
9
|
+
describe 'for enqueue class method' do
|
10
|
+
it 'should support enqueuing plain job' do
|
11
|
+
Backburner::Worker.enqueue TestPlainJob, [7, 9], ttr: 100, pri: 2000
|
12
|
+
pop_one_job('test-plain') do |job, body|
|
13
|
+
assert_equal 'TestPlainJob', body['class']
|
14
|
+
assert_equal [7, 9], body['args']
|
15
15
|
assert_equal 100, job.ttr
|
16
16
|
assert_equal 2000, job.pri
|
17
17
|
end
|
18
18
|
end # plain
|
19
19
|
|
20
|
-
it
|
21
|
-
Backburner::Worker.enqueue TestJob, [3, 4], :
|
20
|
+
it 'should support enqueuing job with class queue priority' do
|
21
|
+
Backburner::Worker.enqueue TestJob, [3, 4], ttr: 100
|
22
22
|
pop_one_job do |job, body|
|
23
|
-
assert_equal
|
24
|
-
assert_equal [3, 4], body[
|
23
|
+
assert_equal 'TestJob', body['class']
|
24
|
+
assert_equal [3, 4], body['args']
|
25
25
|
assert_equal 100, job.ttr
|
26
26
|
assert_equal 100, job.pri
|
27
27
|
end
|
28
28
|
end # queue priority
|
29
29
|
|
30
|
-
it
|
31
|
-
Backburner::Worker.enqueue TestJob, [3, 4], :
|
30
|
+
it 'should support enqueuing job with specified named priority' do
|
31
|
+
Backburner::Worker.enqueue TestJob, [3, 4], ttr: 100, pri: 'high'
|
32
32
|
pop_one_job do |job, body|
|
33
|
-
assert_equal
|
34
|
-
assert_equal [3, 4], body[
|
33
|
+
assert_equal 'TestJob', body['class']
|
34
|
+
assert_equal [3, 4], body['args']
|
35
35
|
assert_equal 100, job.ttr
|
36
36
|
assert_equal 0, job.pri
|
37
37
|
end
|
38
38
|
end # queue named priority
|
39
39
|
|
40
|
-
it
|
40
|
+
it 'should support enqueuing job with class queue respond_timeout' do
|
41
41
|
Backburner::Worker.enqueue TestJob, [3, 4]
|
42
42
|
pop_one_job do |job, body|
|
43
|
-
assert_equal
|
44
|
-
assert_equal [3, 4], body[
|
43
|
+
assert_equal 'TestJob', body['class']
|
44
|
+
assert_equal [3, 4], body['args']
|
45
45
|
assert_equal 300, job.ttr
|
46
46
|
assert_equal 100, job.pri
|
47
47
|
end
|
48
48
|
end # queue respond_timeout
|
49
49
|
|
50
|
-
it
|
51
|
-
Backburner::Worker.enqueue TestJob, [6, 7], :
|
52
|
-
pop_one_job(
|
53
|
-
assert_equal
|
54
|
-
assert_equal [6, 7], body[
|
50
|
+
it 'should support enqueuing job with custom queue' do
|
51
|
+
Backburner::Worker.enqueue TestJob, [6, 7], queue: 'test.bar', pri: 5000
|
52
|
+
pop_one_job('test.bar') do |job, body|
|
53
|
+
assert_equal 'TestJob', body['class']
|
54
|
+
assert_equal [6, 7], body['args']
|
55
55
|
assert_equal 0, job.delay
|
56
56
|
assert_equal 5000, job.pri
|
57
57
|
assert_equal 300, job.ttr
|
58
58
|
end
|
59
59
|
end # custom
|
60
60
|
|
61
|
-
it
|
62
|
-
TestAsyncJob.async(:
|
63
|
-
pop_one_job(
|
64
|
-
assert_equal
|
65
|
-
assert_equal [nil,
|
61
|
+
it 'should support async job' do
|
62
|
+
TestAsyncJob.async(ttr: 100, queue: 'bar.baz.foo').foo(10, 5)
|
63
|
+
pop_one_job('bar.baz.foo') do |job, body|
|
64
|
+
assert_equal 'TestAsyncJob', body['class']
|
65
|
+
assert_equal [nil, 'foo', 10, 5], body['args']
|
66
66
|
assert_equal 100, job.ttr
|
67
67
|
assert_equal Backburner.configuration.default_priority, job.pri
|
68
68
|
end
|
69
69
|
end # async
|
70
70
|
|
71
|
-
it
|
71
|
+
it 'should support enqueueing job with lambda queue' do
|
72
72
|
expected_queue_name = TestLambdaQueueJob.calculated_queue_name
|
73
|
-
Backburner::Worker.enqueue TestLambdaQueueJob, [6, 7], :
|
74
|
-
pop_one_job(expected_queue_name) do |
|
75
|
-
assert_equal
|
76
|
-
assert_equal [6, 7], body[
|
73
|
+
Backburner::Worker.enqueue TestLambdaQueueJob, [6, 7], queue: ->(klass) { klass.calculated_queue_name }
|
74
|
+
pop_one_job(expected_queue_name) do |_job, body|
|
75
|
+
assert_equal 'TestLambdaQueueJob', body['class']
|
76
|
+
assert_equal [6, 7], body['args']
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end # enqueue
|
80
80
|
|
81
|
-
describe "for start class method" do
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
81
|
+
# describe "for start class method" do
|
82
|
+
# it "should initialize and start the worker instance" do
|
83
|
+
# ech = stub
|
84
|
+
# Backburner::Worker.expects(:new).with("foo").returns(ech)
|
85
|
+
# ech.expects(:start)
|
86
|
+
# Backburner::Worker.start("foo")
|
87
|
+
# object = mock()
|
88
|
+
# object.expects(:expected_method).with() { |value| value % 4 == 0 }
|
89
|
+
# object.expected_method(16)
|
90
|
+
# end
|
91
|
+
# end # start
|
92
|
+
|
93
|
+
describe 'for tube_names accessor' do
|
91
94
|
before do
|
92
|
-
Backburner.default_queues <<
|
93
|
-
Backburner.default_queues <<
|
95
|
+
Backburner.default_queues << 'baz'
|
96
|
+
Backburner.default_queues << 'bam'
|
94
97
|
end
|
95
98
|
|
96
|
-
it
|
97
|
-
worker = Backburner::Worker.new([
|
98
|
-
assert_equal [
|
99
|
+
it 'supports retrieving tubes' do
|
100
|
+
worker = Backburner::Worker.new(%w[foo bar])
|
101
|
+
assert_equal %w[foo bar], worker.tube_names
|
99
102
|
end
|
100
103
|
|
101
|
-
it
|
102
|
-
worker = Backburner::Worker.new([[
|
103
|
-
assert_equal [
|
104
|
+
it 'supports single tube array arg' do
|
105
|
+
worker = Backburner::Worker.new([%w[foo bar]])
|
106
|
+
assert_equal %w[foo bar], worker.tube_names
|
104
107
|
end
|
105
108
|
|
106
|
-
it
|
109
|
+
it 'supports empty nil array arg with default values' do
|
107
110
|
worker = Backburner::Worker.new([nil])
|
108
|
-
assert_equal [
|
111
|
+
assert_equal %w[baz bam], worker.tube_names
|
109
112
|
end
|
110
113
|
|
111
|
-
it
|
112
|
-
worker = Backburner::Worker.new(
|
113
|
-
assert_equal [
|
114
|
+
it 'supports single tube arg' do
|
115
|
+
worker = Backburner::Worker.new('foo')
|
116
|
+
assert_equal ['foo'], worker.tube_names
|
114
117
|
end
|
115
118
|
|
116
|
-
it
|
119
|
+
it 'supports empty array arg with default values' do
|
117
120
|
worker = Backburner::Worker.new([])
|
118
|
-
assert_equal [
|
121
|
+
assert_equal %w[baz bam], worker.tube_names
|
119
122
|
end
|
120
123
|
|
121
|
-
it
|
124
|
+
it 'supports nil arg with default values' do
|
122
125
|
worker = Backburner::Worker.new(nil)
|
123
|
-
assert_equal [
|
126
|
+
assert_equal %w[baz bam], worker.tube_names
|
124
127
|
end
|
125
128
|
end # tube_names
|
126
129
|
|
127
|
-
describe
|
130
|
+
describe 'for custom serialization' do
|
128
131
|
before do
|
129
132
|
Backburner.configure do |config|
|
130
133
|
@old_parser = config.job_parser_proc
|
131
134
|
@old_serializer = config.job_serializer_proc
|
132
|
-
config.job_parser_proc =
|
133
|
-
config.job_serializer_proc =
|
135
|
+
config.job_parser_proc = ->(body) { Marshal.load(body) }
|
136
|
+
config.job_serializer_proc = ->(body) { Marshal.dump(body) }
|
134
137
|
end
|
135
138
|
end
|
136
139
|
|
@@ -142,10 +145,10 @@ describe "Backburner::Worker module" do
|
|
142
145
|
end
|
143
146
|
end
|
144
147
|
|
145
|
-
it
|
146
|
-
Backburner::Worker.enqueue TestPlainJob, [7, 9], :
|
147
|
-
pop_one_job(
|
148
|
-
assert_equal
|
148
|
+
it 'should support enqueuing a job' do
|
149
|
+
Backburner::Worker.enqueue TestPlainJob, [7, 9], ttr: 100, pri: 2000
|
150
|
+
pop_one_job('test-plain') do |job, body|
|
151
|
+
assert_equal 'TestPlainJob', body[:class]
|
149
152
|
assert_equal [7, 9], body[:args]
|
150
153
|
assert_equal 100, job.ttr
|
151
154
|
assert_equal 2000, job.pri
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backburner-allq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.49
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Malcolm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: allq_rest
|