exel-sidekiq 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3fcc3d8f156d37752c4590eccf49b68e1e777c99
4
+ data.tar.gz: d5973955df99b74878e54bd33701714fca41aa6b
5
+ SHA512:
6
+ metadata.gz: 5f28626d9fb7d4d710160e0b4f3d5b5e87cde31728b3e1e38b68516c46d43015b78c015d9323ab9a8a1fefaa3e8d4b1f51bd39616758460d81855380c060b021
7
+ data.tar.gz: 9b12729a14ec7985e9333c8c265c96166c88172aa76d6a8f218e0cf76834eaf2e5a9be196bf4a92844b75bc63d6bf14f34694368bb9d904fb850b6ee6b74320f
data/.gitignore ADDED
@@ -0,0 +1,25 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ .idea
24
+ *.iml
25
+ .ruby-*
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in exel-sidekiq.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,14 @@
1
+ guard :rspec, cmd: 'bundle exec rspec' do
2
+ require 'guard/rspec/dsl'
3
+ dsl = Guard::RSpec::Dsl.new(self)
4
+
5
+ # RSpec files
6
+ rspec = dsl.rspec
7
+ watch(rspec.spec_helper) { rspec.spec_dir }
8
+ watch(rspec.spec_support) { rspec.spec_dir }
9
+ watch(rspec.spec_files)
10
+
11
+ # Ruby files
12
+ ruby = dsl.ruby
13
+ dsl.watch_spec_files_for(ruby.lib_files)
14
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 David
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # EXEL::Sidekiq
2
+
3
+ This gem adds Sidekiq support for [EXEL's](https://github.com/47colborne/exel) async command.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'exel-sidekiq'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install exel-sidekiq
18
+
19
+ ## Usage
20
+
21
+ If you wish to use a queue other than default, you may specify it's name in the options passed to `async`. The retry limit
22
+ can also be set, as in the following example:
23
+
24
+ async queue: :my_queue, retry: 3 do
25
+ process with: MyProcessor
26
+ end
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it ( https://github.com/47colborne/exel-sidekiq )
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'exel/sidekiq/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'exel-sidekiq'
8
+ spec.version = EXEL::Sidekiq::VERSION
9
+ spec.authors = ['yroo']
10
+ spec.email = ['dev@yroo.com']
11
+ spec.summary = %q{Async provider for EXEL using Sidekiq}
12
+ spec.description = %q{When used with EXEL (https://github.com/47colborne/exel), the async command will launch a Sidekiq worker}
13
+ spec.homepage = 'https://github.com/47colborne/exel-sidekiq'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'exel', '~> 1'
22
+ spec.add_dependency 'sidekiq', '~> 3'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.6'
25
+ spec.add_development_dependency 'rake', '~> 10'
26
+ spec.add_development_dependency 'rspec', '~> 3'
27
+ spec.add_development_dependency 'guard', '~> 2'
28
+ spec.add_development_dependency 'guard-rspec', '~> 4'
29
+ spec.add_development_dependency 'terminal-notifier', '~> 1'
30
+ spec.add_development_dependency 'terminal-notifier-guard', '~> 1'
31
+ end
@@ -0,0 +1,15 @@
1
+ require 'sidekiq'
2
+
3
+ module EXEL
4
+ module Sidekiq
5
+ class ExecutionWorker
6
+ include ::Sidekiq::Worker
7
+
8
+ def perform(context_uri)
9
+ context = Context.deserialize(context_uri)
10
+ block = context[:_block]
11
+ block.start(context)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,22 @@
1
+ require 'sidekiq'
2
+ require_relative 'execution_worker'
3
+
4
+ module EXEL
5
+ module Sidekiq
6
+ class SidekiqProvider
7
+ def initialize(context)
8
+ @context = context
9
+ end
10
+
11
+ def do_async(block)
12
+ @context[:_block] = block
13
+
14
+ push_args = {'class' => EXEL::Sidekiq::ExecutionWorker, 'args' => [@context.serialize]}
15
+ push_args['queue'] = @context[:queue] if @context[:queue]
16
+ push_args['retry'] = @context[:retry] if @context[:retry]
17
+
18
+ ::Sidekiq::Client.push(push_args)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,5 @@
1
+ module EXEL
2
+ module Sidekiq
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ require 'exel/sidekiq/version'
2
+ require_relative 'sidekiq/sidekiq_provider'
3
+
4
+ module EXEL
5
+ module Sidekiq
6
+ EXEL.configure do |config|
7
+ config.async_provider = EXEL::Sidekiq::SidekiqProvider
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ module EXEL
2
+ module Sidekiq
3
+ describe ExecutionWorker do
4
+ it 'runs the given block with the deserialized context' do
5
+ dsl_block = instance_double(SequenceNode)
6
+ context = Context.new(test1: 'foo', test2: 2, _block: dsl_block)
7
+ context_uri = 'test uri'
8
+
9
+ expect(Context).to receive(:deserialize).with(context_uri).and_return(context)
10
+ expect(dsl_block).to receive(:start).with(context)
11
+ ExecutionWorker.new.perform(context_uri)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,54 @@
1
+ module EXEL
2
+ module Sidekiq
3
+ describe SidekiqProvider do
4
+ subject(:provider) { described_class.new(context) }
5
+ let(:callback) { instance_double(SequenceNode) }
6
+ let(:context) { EXEL::Context.new }
7
+ let(:serialized_context_uri) { 'context_uri' }
8
+
9
+ describe '#do_async' do
10
+ before do
11
+ allow(context).to receive(:serialize).and_return(serialized_context_uri)
12
+ end
13
+
14
+ it 'adds the callback to the context before serializing it' do
15
+ expect(context).to receive(:[]=).with(:_block, callback).ordered
16
+ expect(context).to receive(:serialize).ordered
17
+ provider.do_async(callback)
18
+ end
19
+
20
+ context 'with queue name' do
21
+ let(:context) { EXEL::Context.new(queue: 'import_processor') }
22
+
23
+ it 'pushes the execution worker to the given queue' do
24
+ expect(::Sidekiq::Client).to receive(:push).with('queue' => context[:queue], 'class' => ExecutionWorker, 'args' => [serialized_context_uri])
25
+ provider.do_async(callback)
26
+ end
27
+ end
28
+
29
+ context 'without queue name' do
30
+ it 'pushes the execution worker to the default queue' do
31
+ expect(::Sidekiq::Client).to receive(:push).with('class' => ExecutionWorker, 'args' => [serialized_context_uri])
32
+ provider.do_async(callback)
33
+ end
34
+ end
35
+
36
+ context 'with retries specified' do
37
+ let(:context) { EXEL::Context.new(retry: 1) }
38
+
39
+ it 'pushes the execution worker with a specified number of retries' do
40
+ expect(::Sidekiq::Client).to receive(:push).with('retry' => context[:retry], 'class' => ExecutionWorker, 'args' => [serialized_context_uri])
41
+ provider.do_async(callback)
42
+ end
43
+ end
44
+
45
+ context 'with no retries specified' do
46
+ it 'pushes the execution worker with no specified number of retries' do
47
+ expect(::Sidekiq::Client).to receive(:push).with('class' => ExecutionWorker, 'args' => [serialized_context_uri])
48
+ provider.do_async(callback)
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,5 @@
1
+ require 'exel'
2
+
3
+ Dir[File.expand_path('../../lib/**/*.rb', __FILE__)].each { |f| require f }
4
+
5
+ EXEL.logger = nil
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: exel-sidekiq
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - yroo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: exel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sidekiq
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard-rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '4'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '4'
111
+ - !ruby/object:Gem::Dependency
112
+ name: terminal-notifier
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1'
125
+ - !ruby/object:Gem::Dependency
126
+ name: terminal-notifier-guard
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1'
139
+ description: When used with EXEL (https://github.com/47colborne/exel), the async command
140
+ will launch a Sidekiq worker
141
+ email:
142
+ - dev@yroo.com
143
+ executables: []
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - ".gitignore"
148
+ - ".rspec"
149
+ - Gemfile
150
+ - Guardfile
151
+ - LICENSE.txt
152
+ - README.md
153
+ - Rakefile
154
+ - exel-sidekiq.gemspec
155
+ - lib/exel/sidekiq.rb
156
+ - lib/exel/sidekiq/execution_worker.rb
157
+ - lib/exel/sidekiq/sidekiq_provider.rb
158
+ - lib/exel/sidekiq/version.rb
159
+ - spec/exel/sidekiq/execution_worker_spec.rb
160
+ - spec/exel/sidekiq/sidekiq_provider_spec.rb
161
+ - spec/spec_helper.rb
162
+ homepage: https://github.com/47colborne/exel-sidekiq
163
+ licenses:
164
+ - MIT
165
+ metadata: {}
166
+ post_install_message:
167
+ rdoc_options: []
168
+ require_paths:
169
+ - lib
170
+ required_ruby_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ requirements: []
181
+ rubyforge_project:
182
+ rubygems_version: 2.4.5.1
183
+ signing_key:
184
+ specification_version: 4
185
+ summary: Async provider for EXEL using Sidekiq
186
+ test_files:
187
+ - spec/exel/sidekiq/execution_worker_spec.rb
188
+ - spec/exel/sidekiq/sidekiq_provider_spec.rb
189
+ - spec/spec_helper.rb