exel-sidekiq 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/exel/sidekiq/execution_worker.rb +3 -1
- data/lib/exel/sidekiq/sidekiq_provider.rb +4 -1
- data/lib/exel/sidekiq/version.rb +1 -1
- data/spec/exel/sidekiq/sidekiq_provider_spec.rb +24 -12
- data/spec/spec_helper.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a363f2b4dc4efe7a4d0becc57e82f38b069af9bc
|
4
|
+
data.tar.gz: 5d14b0bbea5e9434c4c21d5e920fcabb4f3e2b37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c44ac7cfeedbbea7d37599e10d7b9456951e97bd2e5d4246c1ae109db1f5590573843f3cf1fa89d64e7a3d2107454496b95304c56396173fbce13018a20a724a
|
7
|
+
data.tar.gz: 68170035d52b843fdc52cfe41bd4f2bca77973c477533d65062d303f45f2c8800aecb230f26789c6330eed17883d458dfcd97246edc1c1227bcb8b631aa50375
|
data/README.md
CHANGED
@@ -27,6 +27,8 @@ By requiring this gem, Sidekiq support will automatically be added to [EXEL](htt
|
|
27
27
|
process with: MyProcessor
|
28
28
|
end
|
29
29
|
|
30
|
+
You can optionally provide a string in ```context[:async_label]``` which will be passed to the Sidekiq worker. This is intended to be a human readable label that will be visible on the Sidekiq admin pages to assist in debugging and monitoring your jobs.
|
31
|
+
|
30
32
|
## Contributing
|
31
33
|
|
32
34
|
1. Fork it ( https://github.com/47colborne/exel-sidekiq )
|
@@ -5,7 +5,9 @@ module EXEL
|
|
5
5
|
class ExecutionWorker
|
6
6
|
include ::Sidekiq::Worker
|
7
7
|
|
8
|
-
def perform(context_uri)
|
8
|
+
def perform(context_uri, label = nil)
|
9
|
+
EXEL.logger.debug("[#{label}] Worker starting")
|
10
|
+
|
9
11
|
context = Context.deserialize(context_uri)
|
10
12
|
block = context[:_block]
|
11
13
|
block.start(context)
|
@@ -11,7 +11,10 @@ module EXEL
|
|
11
11
|
def do_async(block)
|
12
12
|
@context[:_block] = block
|
13
13
|
|
14
|
-
|
14
|
+
worker_args = [@context.serialize, @context[:async_label]].compact
|
15
|
+
|
16
|
+
# noinspection RubyStringKeysInHashInspection
|
17
|
+
push_args = {'class' => EXEL::Sidekiq::ExecutionWorker, 'args' => worker_args}
|
15
18
|
push_args['queue'] = @context[:queue] if @context[:queue]
|
16
19
|
push_args['retry'] = @context[:retry] if @context[:retry]
|
17
20
|
|
data/lib/exel/sidekiq/version.rb
CHANGED
@@ -17,20 +17,34 @@ module EXEL
|
|
17
17
|
provider.do_async(callback)
|
18
18
|
end
|
19
19
|
|
20
|
+
it 'passes the serialized context URI to the worker' do
|
21
|
+
expect(::Sidekiq::Client).to receive(:push).with(hash_including('class' => ExecutionWorker,
|
22
|
+
'args' => [serialized_context_uri]))
|
23
|
+
provider.do_async(callback)
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when label is present in the context' do
|
27
|
+
let(:context) { EXEL::Context.new(async_label: 'label') }
|
28
|
+
|
29
|
+
it 'includes the label in the args' do
|
30
|
+
args = [serialized_context_uri, 'label']
|
31
|
+
expect(::Sidekiq::Client).to receive(:push).with(hash_including('class' => ExecutionWorker, 'args' => args))
|
32
|
+
provider.do_async(callback)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
20
36
|
context 'with queue name' do
|
21
37
|
let(:context) { EXEL::Context.new(queue: 'import_processor') }
|
22
38
|
|
23
|
-
it 'pushes
|
24
|
-
expect(::Sidekiq::Client).to receive(:push).with(
|
25
|
-
'queue' => context[:queue], 'class' => ExecutionWorker, 'args' => [serialized_context_uri])
|
39
|
+
it 'pushes to the given queue' do
|
40
|
+
expect(::Sidekiq::Client).to receive(:push).with(hash_including('queue' => context[:queue]))
|
26
41
|
provider.do_async(callback)
|
27
42
|
end
|
28
43
|
end
|
29
44
|
|
30
45
|
context 'without queue name' do
|
31
|
-
it 'pushes
|
32
|
-
expect(::Sidekiq::Client).to receive(:push).with(
|
33
|
-
'class' => ExecutionWorker, 'args' => [serialized_context_uri])
|
46
|
+
it 'pushes to the default queue' do
|
47
|
+
expect(::Sidekiq::Client).to receive(:push).with(hash_not_including('queue'))
|
34
48
|
provider.do_async(callback)
|
35
49
|
end
|
36
50
|
end
|
@@ -38,17 +52,15 @@ module EXEL
|
|
38
52
|
context 'with retries specified' do
|
39
53
|
let(:context) { EXEL::Context.new(retry: 1) }
|
40
54
|
|
41
|
-
it 'pushes the
|
42
|
-
expect(::Sidekiq::Client).to receive(:push).with(
|
43
|
-
'retry' => context[:retry], 'class' => ExecutionWorker, 'args' => [serialized_context_uri])
|
55
|
+
it 'pushes the worker with a specified number of retries' do
|
56
|
+
expect(::Sidekiq::Client).to receive(:push).with(hash_including('retry' => context[:retry]))
|
44
57
|
provider.do_async(callback)
|
45
58
|
end
|
46
59
|
end
|
47
60
|
|
48
61
|
context 'with no retries specified' do
|
49
|
-
it 'pushes the
|
50
|
-
expect(::Sidekiq::Client).to receive(:push).with(
|
51
|
-
'class' => ExecutionWorker, 'args' => [serialized_context_uri])
|
62
|
+
it 'pushes the worker with no specified number of retries' do
|
63
|
+
expect(::Sidekiq::Client).to receive(:push).with(hash_not_including('retry'))
|
52
64
|
provider.do_async(callback)
|
53
65
|
end
|
54
66
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exel-sidekiq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yroo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: exel
|