queue-bus 0.5.1 → 0.5.2
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.
- data/lib/queue_bus/version.rb +1 -1
- data/lib/queue_bus/worker.rb +4 -3
- data/spec/subscriber_spec.rb +7 -7
- data/spec/worker_spec.rb +4 -4
- metadata +2 -2
data/lib/queue_bus/version.rb
CHANGED
data/lib/queue_bus/worker.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
module QueueBus
|
2
2
|
class Worker
|
3
3
|
|
4
|
-
def self.perform(
|
4
|
+
def self.perform(json)
|
5
5
|
klass = nil
|
6
|
+
attributes = ::QueueBus::Util.decode(json)
|
6
7
|
begin
|
7
8
|
class_name = attributes["bus_class_proxy"]
|
8
9
|
klass = ::QueueBus::Util.constantize(class_name)
|
@@ -15,9 +16,9 @@ module QueueBus
|
|
15
16
|
end
|
16
17
|
|
17
18
|
# all our workers include this one
|
18
|
-
def perform(
|
19
|
+
def perform(json)
|
19
20
|
# instance method level support for sidekiq
|
20
|
-
self.class.perform(
|
21
|
+
self.class.perform(json)
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
data/spec/subscriber_spec.rb
CHANGED
@@ -96,7 +96,7 @@ require 'spec_helper'
|
|
96
96
|
|
97
97
|
QueueBus::Runner1.value.should == 0
|
98
98
|
QueueBus::Runner2.value.should == 0
|
99
|
-
QueueBus::Util.constantize(hash["class"]).perform(
|
99
|
+
QueueBus::Util.constantize(hash["class"]).perform(*hash["args"])
|
100
100
|
QueueBus::Runner1.value.should == 1
|
101
101
|
QueueBus::Runner2.value.should == 0
|
102
102
|
|
@@ -113,7 +113,7 @@ require 'spec_helper'
|
|
113
113
|
|
114
114
|
QueueBus::Runner1.value.should == 1
|
115
115
|
QueueBus::Runner2.value.should == 0
|
116
|
-
QueueBus::Util.constantize(hash["class"]).perform(
|
116
|
+
QueueBus::Util.constantize(hash["class"]).perform(*hash["args"])
|
117
117
|
QueueBus::Runner1.value.should == 2
|
118
118
|
QueueBus::Runner2.value.should == 0
|
119
119
|
|
@@ -160,7 +160,7 @@ require 'spec_helper'
|
|
160
160
|
|
161
161
|
QueueBus::Runner1.value.should == 0
|
162
162
|
QueueBus::Runner2.value.should == 0
|
163
|
-
QueueBus::Util.constantize(hash["class"]).perform(
|
163
|
+
QueueBus::Util.constantize(hash["class"]).perform(*hash["args"])
|
164
164
|
QueueBus::Runner1.value.should == 1
|
165
165
|
QueueBus::Runner2.value.should == 0
|
166
166
|
|
@@ -172,7 +172,7 @@ require 'spec_helper'
|
|
172
172
|
|
173
173
|
QueueBus::Runner1.value.should == 1
|
174
174
|
QueueBus::Runner2.value.should == 0
|
175
|
-
QueueBus::Util.constantize(hash["class"]).perform(
|
175
|
+
QueueBus::Util.constantize(hash["class"]).perform(*hash["args"])
|
176
176
|
QueueBus::Runner1.value.should == 1
|
177
177
|
QueueBus::Runner2.value.should == 1
|
178
178
|
end
|
@@ -213,7 +213,7 @@ require 'spec_helper'
|
|
213
213
|
|
214
214
|
QueueBus::Runner1.value.should == 0
|
215
215
|
QueueBus::Runner2.value.should == 0
|
216
|
-
QueueBus::Util.constantize(hash1["class"]).perform(
|
216
|
+
QueueBus::Util.constantize(hash1["class"]).perform(*hash1["args"])
|
217
217
|
QueueBus::Runner1.value.should == 0
|
218
218
|
QueueBus::Runner2.value.should == 1
|
219
219
|
|
@@ -224,7 +224,7 @@ require 'spec_helper'
|
|
224
224
|
|
225
225
|
QueueBus::Runner1.value.should == 0
|
226
226
|
QueueBus::Runner2.value.should == 1
|
227
|
-
QueueBus::Util.constantize(hash2["class"]).perform(
|
227
|
+
QueueBus::Util.constantize(hash2["class"]).perform(*hash2["args"])
|
228
228
|
QueueBus::Runner1.value.should == 1
|
229
229
|
QueueBus::Runner2.value.should == 1
|
230
230
|
|
@@ -239,7 +239,7 @@ require 'spec_helper'
|
|
239
239
|
|
240
240
|
QueueBus::Runner1.value.should == 1
|
241
241
|
QueueBus::Runner2.value.should == 1
|
242
|
-
QueueBus::Util.constantize(hash["class"]).perform(
|
242
|
+
QueueBus::Util.constantize(hash["class"]).perform(*hash["args"])
|
243
243
|
QueueBus::Runner1.value.should == 1
|
244
244
|
QueueBus::Runner2.value.should == 2
|
245
245
|
|
data/spec/worker_spec.rb
CHANGED
@@ -5,19 +5,19 @@ module QueueBus
|
|
5
5
|
it "should proxy to given class" do
|
6
6
|
hash = {"bus_class_proxy" => "QueueBus::Driver", "ok" => true}
|
7
7
|
QueueBus::Driver.should_receive(:perform).with(hash)
|
8
|
-
QueueBus::Worker.perform(hash)
|
8
|
+
QueueBus::Worker.perform(JSON.generate(hash))
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should use instance" do
|
12
12
|
hash = {"bus_class_proxy" => "QueueBus::Rider", "ok" => true}
|
13
13
|
QueueBus::Rider.should_receive(:perform).with(hash)
|
14
|
-
QueueBus::Worker.new.perform(hash)
|
14
|
+
QueueBus::Worker.new.perform(JSON.generate(hash))
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should not freak out if class not there anymore" do
|
18
18
|
hash = {"bus_class_proxy" => "QueueBus::BadClass", "ok" => true}
|
19
19
|
lambda {
|
20
|
-
QueueBus::Worker.perform(hash)
|
20
|
+
QueueBus::Worker.perform(JSON.generate(hash))
|
21
21
|
}.should_not raise_error
|
22
22
|
end
|
23
23
|
|
@@ -25,7 +25,7 @@ module QueueBus
|
|
25
25
|
hash = {"bus_class_proxy" => "QueueBus::Rider", "ok" => true}
|
26
26
|
QueueBus::Rider.should_receive(:perform).with(hash).and_raise("rider crash")
|
27
27
|
lambda {
|
28
|
-
QueueBus::Worker.perform(hash)
|
28
|
+
QueueBus::Worker.perform(JSON.generate(hash))
|
29
29
|
}.should raise_error
|
30
30
|
end
|
31
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: queue-bus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-01-
|
12
|
+
date: 2015-01-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|