resque-bus 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/README.mdown CHANGED
@@ -221,7 +221,7 @@ That will use the default (resque) namespace which can be helpful for using the
221
221
  ```ruby
222
222
  # config
223
223
  Resque.redis = "192.168.1.0:6379"
224
- ResqusBus.redis.namespace = :get_on_the_bus
224
+ ResqueBus.redis.namespace = :get_on_the_bus
225
225
  ```
226
226
 
227
227
  ### Local Mode
data/lib/resque-bus.rb CHANGED
@@ -3,6 +3,10 @@ require "resque_bus/version"
3
3
  require 'redis/namespace'
4
4
  require 'resque'
5
5
 
6
+ module QueueBus
7
+ autoload :Worker, 'resque_bus/compatibility'
8
+ end
9
+
6
10
  module ResqueBus
7
11
 
8
12
  autoload :Application, 'resque_bus/application'
@@ -0,0 +1,22 @@
1
+ # these can be in the queue from the new queue-bus version
2
+ module QueueBus
3
+ class Worker
4
+
5
+ def self.perform(json)
6
+ attributes = ::Resque.decode(json)
7
+ class_name = attributes["bus_class_proxy"]
8
+
9
+ case class_name
10
+ when "::QueueBus::Driver", "QueueBus::Driver"
11
+ ResqueBus::Driver.perform(attributes)
12
+ when "::QueueBus::Rider", "QueueBus::Rider"
13
+ ResqueBus::Rider.perform(attributes)
14
+ when "::QueueBus::Publisher", "QueueBus::Publisher"
15
+ ResqueBus::Publisher.perform(attributes["bus_event_type"], attributes)
16
+ else
17
+ klass = ::ResqueBus::Util.constantize(class_name)
18
+ klass.perform(attributes)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,5 +1,5 @@
1
1
  module Resque
2
2
  module Bus
3
- VERSION = "0.3.5"
3
+ VERSION = "0.3.6"
4
4
  end
5
5
  end
@@ -0,0 +1,93 @@
1
+ require 'spec_helper'
2
+
3
+ describe "migration compatibility" do
4
+ before(:each) do
5
+ ResqueBus.dispatch("r1") do
6
+ subscribe "event_name" do |attributes|
7
+ ResqueBus::Runner1.run(attributes)
8
+ end
9
+ end
10
+
11
+ ResqueBus::TaskManager.new(false).subscribe!
12
+
13
+ @incoming = Resque::Worker.new(:resquebus_incoming)
14
+ @incoming.register_worker
15
+
16
+ @new_incoming = Resque::Worker.new(:bus_incoming)
17
+ @new_incoming.register_worker
18
+
19
+ @rider = Resque::Worker.new(:r1_default)
20
+ @rider.register_worker
21
+ end
22
+
23
+ it "should still drive as expected" do
24
+ val = ResqueBus.redis.lpop("queue:bus_incoming")
25
+ val.should == nil
26
+
27
+ args = [ JSON.generate({"bus_class_proxy"=>"QueueBus::Driver", "bus_event_type" => "event_name", "two"=>"here", "one"=>1, "id" => 12}) ]
28
+ item = {:class => "QueueBus::Worker", :args => args}
29
+
30
+ ResqueBus.redis.sadd(:queues, "bus_incoming")
31
+ ResqueBus.redis.rpush "queue:bus_incoming", Resque.encode(item)
32
+
33
+ ResqueBus::Runner1.value.should == 0
34
+
35
+ perform_next_job @new_incoming
36
+
37
+ ResqueBus::Runner1.value.should == 0
38
+
39
+ perform_next_job @rider
40
+
41
+ ResqueBus::Runner1.value.should == 1
42
+ end
43
+
44
+ it "should still ride as expected" do
45
+ val = ResqueBus.redis.lpop("queue:r1_default")
46
+ val.should == nil
47
+
48
+ args = [ {"bus_rider_app_key"=>"r1", "x" => "y", "bus_event_type" => "event_name",
49
+ "bus_rider_sub_key"=>"event_name", "bus_rider_queue" => "default",
50
+ "bus_rider_class_name"=>"::ResqueBus::Rider"}]
51
+ item = {:class => "ResqueBus::Rider", :args => args}
52
+
53
+ args = [ JSON.generate({"bus_class_proxy"=>"QueueBus::Rider","bus_rider_app_key"=>"r1", "x" => "y",
54
+ "bus_event_type" => "event_name", "bus_rider_sub_key"=>"event_name",
55
+ "bus_rider_queue" => "default"}) ]
56
+ item = {:class => "QueueBus::Worker", :args => args}
57
+
58
+ ResqueBus.redis.sadd(:queues, "r1_default")
59
+ ResqueBus.redis.rpush "queue:r1_default", Resque.encode(item)
60
+
61
+ ResqueBus::Runner1.value.should == 0
62
+
63
+ perform_next_job @rider
64
+
65
+ ResqueBus::Runner1.value.should == 1
66
+ end
67
+
68
+ it "should still publish as expected" do
69
+ val = ResqueBus.redis.lpop("queue:bus_incoming")
70
+ val.should == nil
71
+
72
+ args = [ JSON.generate({"bus_class_proxy" => "QueueBus::Publisher", "bus_event_type"=>"event_name", "two"=>"here", "one"=>1, "id" => 12}) ]
73
+ item = {:class => "QueueBus::Worker", :args => args}
74
+
75
+ ResqueBus.redis.sadd(:queues, "bus_incoming")
76
+ ResqueBus.redis.rpush "queue:bus_incoming", Resque.encode(item)
77
+
78
+ ResqueBus::Runner1.value.should == 0
79
+
80
+ perform_next_job @new_incoming # publish
81
+
82
+ ResqueBus::Runner1.value.should == 0
83
+
84
+ perform_next_job @incoming # drive
85
+
86
+ ResqueBus::Runner1.value.should == 0
87
+
88
+ perform_next_job @rider # ride
89
+
90
+ ResqueBus::Runner1.value.should == 1
91
+
92
+ end
93
+ end
data/spec/driver_spec.rb CHANGED
@@ -80,11 +80,11 @@ module ResqueBus
80
80
 
81
81
  hash = JSON.parse(ResqueBus.redis.lpop("queue:default"))
82
82
  hash["class"].should == "::ResqueBus::Rider"
83
- hash["args"][0].should == {"bus_rider_app_key"=>"app3", "x" => "y", "bus_event_type" => "event5", "bus_rider_sub_key"=>"event[45]", "bus_rider_queue" => "default"}.merge(bus_attrs)
83
+ hash["args"][0].should == {"bus_rider_app_key"=>"app3", "x" => "y", "bus_event_type" => "event5", "bus_rider_sub_key"=>"event5", "bus_rider_queue" => "default"}.merge(bus_attrs)
84
84
 
85
85
  hash = JSON.parse(ResqueBus.redis.lpop("queue:default"))
86
86
  hash["class"].should == "::ResqueBus::Rider"
87
- hash["args"][0].should == {"bus_rider_app_key"=>"app3", "x" => "y", "bus_event_type" => "event5", "bus_rider_sub_key"=>"event5", "bus_rider_queue" => "default"}.merge(bus_attrs)
87
+ hash["args"][0].should == {"bus_rider_app_key"=>"app3", "x" => "y", "bus_event_type" => "event5", "bus_rider_sub_key"=>"event[45]", "bus_rider_queue" => "default"}.merge(bus_attrs)
88
88
  end
89
89
  end
90
90
  end
data/spec/spec_helper.rb CHANGED
@@ -32,9 +32,9 @@ module ResqueBus
32
32
  end
33
33
 
34
34
  def perform_next_job(worker, &block)
35
- return unless job = @worker.reserve
36
- @worker.perform(job, &block)
37
- @worker.done_working
35
+ return unless job = worker.reserve
36
+ worker.perform(job, &block)
37
+ worker.done_working
38
38
  end
39
39
 
40
40
  def test_sub(event_name, queue="default")
@@ -50,9 +50,6 @@ def test_list(*args)
50
50
  out
51
51
  end
52
52
 
53
-
54
- Resque::Scheduler.mute = true
55
-
56
53
  RSpec.configure do |config|
57
54
  config.mock_framework = :rspec
58
55
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-bus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
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: 2014-05-14 00:00:00.000000000 Z
12
+ date: 2015-03-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: resque
@@ -155,6 +155,7 @@ extra_rdoc_files: []
155
155
  files:
156
156
  - .gitignore
157
157
  - .rbenv-version
158
+ - .rspec
158
159
  - .rvmrc
159
160
  - Gemfile
160
161
  - MIT-LICENSE
@@ -162,6 +163,7 @@ files:
162
163
  - Rakefile
163
164
  - lib/resque-bus.rb
164
165
  - lib/resque_bus/application.rb
166
+ - lib/resque_bus/compatibility.rb
165
167
  - lib/resque_bus/dispatch.rb
166
168
  - lib/resque_bus/driver.rb
167
169
  - lib/resque_bus/heartbeat.rb
@@ -181,6 +183,7 @@ files:
181
183
  - lib/tasks/resquebus.rake
182
184
  - resque-bus.gemspec
183
185
  - spec/application_spec.rb
186
+ - spec/compatibility_spec.rb
184
187
  - spec/dispatch_spec.rb
185
188
  - spec/driver_spec.rb
186
189
  - spec/heartbeat_spec.rb
@@ -220,6 +223,7 @@ specification_version: 3
220
223
  summary: A simple event bus on top of Resque
221
224
  test_files:
222
225
  - spec/application_spec.rb
226
+ - spec/compatibility_spec.rb
223
227
  - spec/dispatch_spec.rb
224
228
  - spec/driver_spec.rb
225
229
  - spec/heartbeat_spec.rb