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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a32d28307810ce39c5e22962bd27e9e7cd7bc8d
4
- data.tar.gz: c20243b2f7d01719984e9370c87b00ff5b77913e
3
+ metadata.gz: a363f2b4dc4efe7a4d0becc57e82f38b069af9bc
4
+ data.tar.gz: 5d14b0bbea5e9434c4c21d5e920fcabb4f3e2b37
5
5
  SHA512:
6
- metadata.gz: d4a66a8bdbcc85f3dfb3d952ba6825ceda812fd99aa7e8b4f35ee16232f47395b2248fae859dd5caa6dae554406fe290dff7fb444a7f8e34c78833c0e9e7e18e
7
- data.tar.gz: cd339ab53034b3403cadf860b13dc084d77d6161298a2d3a665d31d2a92dff27e948dabb6b8504f897f8580fa97834593c8c3abddaad83dde43389b888a7cae4
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
- push_args = {'class' => EXEL::Sidekiq::ExecutionWorker, 'args' => [@context.serialize]}
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
 
@@ -1,5 +1,5 @@
1
1
  module EXEL
2
2
  module Sidekiq
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'.freeze
4
4
  end
5
5
  end
@@ -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 the execution worker to the given queue' do
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 the execution worker to the default queue' do
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 execution worker with a specified number of retries' do
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 execution worker with no specified number of retries' do
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
@@ -1,4 +1,5 @@
1
1
  require 'exel'
2
+ require 'sidekiq/testing'
2
3
 
3
4
  Dir[File.expand_path('../../lib/**/*.rb', __FILE__)].each { |f| require f }
4
5
 
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.1
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-01-05 00:00:00.000000000 Z
11
+ date: 2016-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: exel