sidekiq-bus 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-gemset +2 -0
- data/.ruby-version +1 -0
- data/README.mdown +22 -139
- data/lib/sidekiq-bus.rb +0 -4
- data/lib/sidekiq_bus/tasks.rb +2 -82
- data/lib/sidekiq_bus/version.rb +1 -1
- data/sidekiq-bus.gemspec +6 -3
- data/spec/adapter/integration_spec.rb +113 -0
- data/spec/driver_spec.rb +1 -1
- data/spec/spec_helper.rb +12 -0
- metadata +52 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7fe08a16a8b8372bba7ddbfcfe8c59172d1f8d0
|
4
|
+
data.tar.gz: 73b19c7ef93c76e6fc35af205f9161a736177e44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 672c3b9b603611b05d910fc913f4378d08995639e90706a15596fc509428bb631943341a5d3531b981ca698843c1d517166d65b1a948b87178c5973fb9d66f57
|
7
|
+
data.tar.gz: 83cb7199def75ffebf8d649dfea44b9773aa70c13999a078c361bebfa6e2a3368809dbe54cd878d15bd0f89fa98335d475353f98dfe1835edab6b54d11221522
|
data/.ruby-gemset
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.5
|
data/README.mdown
CHANGED
@@ -1,38 +1,40 @@
|
|
1
|
-
##
|
1
|
+
## Sidekiq Bus
|
2
2
|
|
3
|
-
This gem
|
3
|
+
This gem provides an adapter for Sidekiq for use in the [queue-bus](https://github.com/queue-bus/queue-bus) system.
|
4
|
+
It uses Redis and the Sidekiq that you are already using to allow simple asynchronous communication between apps.
|
4
5
|
|
5
6
|
### Install
|
6
7
|
|
7
|
-
To install, include the '
|
8
|
+
To install, include the 'sidekiq-bus' gem and add the following to your Rakefile:
|
8
9
|
|
9
10
|
```ruby
|
10
11
|
require "sidekiq_bus/tasks"
|
11
12
|
```
|
12
13
|
|
14
|
+
|
13
15
|
### Example
|
14
16
|
|
15
17
|
Application A can publish an event
|
16
18
|
|
17
19
|
```ruby
|
18
|
-
#
|
19
|
-
|
20
|
+
# pick an adapter
|
21
|
+
require 'sidekiq-bus' # (or other adapter)
|
20
22
|
|
21
23
|
# business logic
|
22
|
-
|
24
|
+
QueueBus.publish("user_created", "id" => 42, "first_name" => "John", "last_name" => "Smith")
|
23
25
|
|
24
26
|
# or do it later
|
25
|
-
|
27
|
+
QueueBus.publish_at(1.hour.from_now, "user_created", "id" => 42, "first_name" => "John", "last_name" => "Smith")
|
26
28
|
```
|
27
29
|
|
28
30
|
Application B is subscribed to events
|
29
31
|
|
30
32
|
```ruby
|
31
|
-
#
|
32
|
-
|
33
|
+
# pick an adapter
|
34
|
+
require 'sidekiq-bus' # (or other adapter)
|
33
35
|
|
34
36
|
# initializer
|
35
|
-
|
37
|
+
QueueBus.dispatch("app_b") do
|
36
38
|
# processes event on app_b_default queue
|
37
39
|
# subscribe is short-hand to subscribe to your 'default' queue and this block with process events with the name "user_created"
|
38
40
|
subscribe "user_created" do |attributes|
|
@@ -65,7 +67,7 @@ Applications can also subscribe within classes using the provided `Subscriber` m
|
|
65
67
|
|
66
68
|
```ruby
|
67
69
|
class SimpleSubscriber
|
68
|
-
include
|
70
|
+
include QueueBus::Subscriber
|
69
71
|
subscribe :my_method
|
70
72
|
|
71
73
|
def my_method(attributes)
|
@@ -78,7 +80,7 @@ The following is equivalent to the original initializer and shows more options:
|
|
78
80
|
|
79
81
|
```ruby
|
80
82
|
class OtherSubscriber
|
81
|
-
include
|
83
|
+
include QueueBus::Subscriber
|
82
84
|
application :app_b
|
83
85
|
|
84
86
|
subscribe :user_created
|
@@ -110,122 +112,11 @@ Note: This subscribes when this class is loaded, so it needs to be in your load
|
|
110
112
|
|
111
113
|
Each app needs to tell Redis about its subscriptions:
|
112
114
|
|
113
|
-
$ rake
|
114
|
-
|
115
|
-
The subscription block is run inside a Resque worker which needs to be started for each app.
|
116
|
-
|
117
|
-
$ rake resquebus:setup resque:work
|
118
|
-
|
119
|
-
The incoming queue also needs to be processed on a dedicated or all the app servers.
|
120
|
-
|
121
|
-
$ rake resquebus:driver resque:work
|
122
|
-
|
123
|
-
If you want retry to work for subscribing apps, you should run resque-scheduler
|
124
|
-
|
125
|
-
$ rake resque:scheduler
|
126
|
-
|
127
|
-
### Adapters
|
128
|
-
|
129
|
-
ResqueBus now supports multiple adapters! By default ResqueBus uses Resque but you can now configure your application to use Sidekiq to drive and subscribe the bus.
|
130
|
-
|
131
|
-
First be sure to configure ResqueBus to use Sidekiq early in your applications' initialization cycle:
|
132
|
-
```
|
133
|
-
ResqueBus.adapter = 'Sidekiq'
|
134
|
-
```
|
135
|
-
You will be responsible for setting up the queues for your Sidekiq clients however you can get the appropriate queue names with the following tasks:
|
136
|
-
For driving applications:
|
137
|
-
```
|
138
|
-
$ rake resquebus:driver:sidekiq
|
139
|
-
```
|
140
|
-
For subscribing applications:
|
141
|
-
```
|
142
|
-
$ rake resquebus:setup:sidekiq
|
143
|
-
```
|
144
|
-
These tasks will provide the queue_names and some minimal suggestions for starting the client.
|
145
|
-
|
146
|
-
Your subscribing applications will still need to also use the appropriate rake task:
|
147
|
-
```
|
148
|
-
$ rake resquebus:subscribe:sidekiq
|
149
|
-
```
|
150
|
-
|
151
|
-
At the moment you are expected to include the Sidekiq gem in your own applications.
|
152
|
-
|
153
|
-
And yes we are planning on renaming and restructuring the project! Please contact the maintainer if you would like to add a different adapter.
|
115
|
+
$ rake queuebus:subscribe
|
154
116
|
|
155
|
-
|
117
|
+
You'll then need to run Sidekiq. Make sure the bus_incoming queues and the ones you are using are included.
|
156
118
|
|
157
|
-
|
158
|
-
It uses resque-scheduler to trigger the events. You can enable it in your Rakefile.
|
159
|
-
|
160
|
-
```ruby
|
161
|
-
# resque.rake
|
162
|
-
namespace :resque do
|
163
|
-
task :setup => [:environment] do
|
164
|
-
ResqueBus.heartbeat!
|
165
|
-
end
|
166
|
-
end
|
167
|
-
```
|
168
|
-
|
169
|
-
Or add it to your `schedule.yml` directly
|
170
|
-
|
171
|
-
```yaml
|
172
|
-
resquebus_heartbeat:
|
173
|
-
cron: "* * * * *"
|
174
|
-
class: "::ResqueBus::Heartbeat"
|
175
|
-
queue: resquebus_incoming
|
176
|
-
description: "I publish a heartbeat_minutes event every minute"
|
177
|
-
```
|
178
|
-
|
179
|
-
It is the equivalent of doing this every minute
|
180
|
-
|
181
|
-
```ruby
|
182
|
-
seconds = minutes * (60)
|
183
|
-
hours = minutes / (60)
|
184
|
-
days = minutes / (60*24)
|
185
|
-
|
186
|
-
now = Time.at(seconds)
|
187
|
-
|
188
|
-
attributes = {}
|
189
|
-
|
190
|
-
now = Time.now
|
191
|
-
seconds = now.to_i
|
192
|
-
ResqueBus.publish("hearbeat_minutes", {
|
193
|
-
"epoch_seconds" => seconds,
|
194
|
-
"epoch_minutes" => seconds / 1.minute,
|
195
|
-
"epoch_hours" => seconds / 1.hour,
|
196
|
-
"epoch_days" => seconds / 1.day,
|
197
|
-
"minute" => now.min
|
198
|
-
"hour" => now.hour
|
199
|
-
"day" => now.day
|
200
|
-
"month" => now.month
|
201
|
-
"year" => now.year
|
202
|
-
"yday" => now.yday
|
203
|
-
"wday" => now.wday
|
204
|
-
})
|
205
|
-
```
|
206
|
-
|
207
|
-
This allows you do something like this:
|
208
|
-
|
209
|
-
```ruby
|
210
|
-
ResqueBus.dispatch("app_c") do
|
211
|
-
# runs at 10:20, 11:20, etc
|
212
|
-
subscribe "once_an_hour", 'bus_event_type' => 'heartbeat_minutes', 'minute' => 20 do |attributes|
|
213
|
-
Sitemap.generate!
|
214
|
-
end
|
215
|
-
|
216
|
-
# runs every five minutes
|
217
|
-
subscribe "every_five_minutes", 'bus_event_type' => 'heartbeat_minutes' do |attributes|
|
218
|
-
next unless attributes["epoch_minutes"] % 5 == 0
|
219
|
-
HealthCheck.run!
|
220
|
-
end
|
221
|
-
|
222
|
-
# runs at 8am on the first of every month
|
223
|
-
subscribe "new_month_morning", 'bus_event_type' => 'heartbeat_minutes', 'day' => 1, hour' => 8, 'minute' => 0, do |attributes|
|
224
|
-
next unless attributes["epoch_minutes"] % 5 == 0
|
225
|
-
Token.old.expire!
|
226
|
-
end
|
227
|
-
end
|
228
|
-
```
|
119
|
+
$ bundle exec sidekiq -q default -q app_b_default -q bus_incoming
|
229
120
|
|
230
121
|
### Local Mode
|
231
122
|
|
@@ -233,32 +124,24 @@ For development, a local mode is provided and is specified in the configuration.
|
|
233
124
|
|
234
125
|
```ruby
|
235
126
|
# config
|
236
|
-
|
127
|
+
QueueBus.local_mode = :standalone
|
237
128
|
or
|
238
|
-
|
129
|
+
QueueBus.local_mode = :inline
|
239
130
|
```
|
240
131
|
|
241
|
-
Standalone mode does not require a separate
|
132
|
+
Standalone mode does not require a separate queuebus:driver task to be running to process the
|
242
133
|
incoming queue. Simply publishing to the bus will distribute the incoming events
|
243
|
-
to the appropriate application specific queue. A separate
|
134
|
+
to the appropriate application specific queue. A separate queuebus:work task does
|
244
135
|
still need to be run to process these events
|
245
136
|
|
246
137
|
Inline mode skips queue processing entirely and directly dispatches the
|
247
138
|
event to the appropriate code block.
|
248
139
|
|
249
|
-
You can also say `
|
140
|
+
You can also say `QueueBus.local_mode = :suppress` to turn off publishing altogether.
|
250
141
|
This can be helpful inside some sort of migration, for example.
|
251
142
|
|
252
143
|
### TODO
|
253
144
|
|
254
|
-
* Sidekiq adapter
|
255
|
-
* Refactor rake tasks for resque/sidekiq
|
256
|
-
* Refactor to a storage adapter for Redis, so we can store subscription info in MySQL or something else
|
257
145
|
* Replace local modes with adapters
|
258
|
-
* There are a few spots in the code with TODO notes
|
259
|
-
* Make this not freak out in development without Redis or when Redis is down
|
260
146
|
* We might not actually need to publish in tests
|
261
147
|
* Add some rspec helpers for the apps to use: should_ post an event_publish or something along those lines
|
262
|
-
* Allow calling resquebus:setup and resquebus:driver together (append to ENV['QUEUES'], don't replace it)
|
263
|
-
|
264
|
-
Copyright (c) 2011 Brian Leonard, released under the MIT license
|
data/lib/sidekiq-bus.rb
CHANGED
data/lib/sidekiq_bus/tasks.rb
CHANGED
@@ -1,93 +1,13 @@
|
|
1
1
|
# require 'sidekiq_bus/tasks'
|
2
2
|
# will give you these tasks
|
3
3
|
|
4
|
+
require "queue_bus/tasks"
|
4
5
|
|
5
|
-
|
6
|
-
namespace :sidekiqbus do
|
7
|
-
|
8
|
-
desc "Setup will configure a resque task to run before resque:work"
|
9
|
-
task :setup => [ :preload ] do
|
10
|
-
|
11
|
-
if ENV['QUEUES'].nil?
|
12
|
-
manager = ::QueueBus::TaskManager.new(true)
|
13
|
-
queues = manager.queue_names
|
14
|
-
ENV['QUEUES'] = queues.join(",")
|
15
|
-
else
|
16
|
-
queues = ENV['QUEUES'].split(",")
|
17
|
-
end
|
18
|
-
|
19
|
-
if queues.size == 1
|
20
|
-
puts " >> Working Queue : #{queues.first}"
|
21
|
-
else
|
22
|
-
puts " >> Working Queues: #{queues.join(", ")}"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
desc "Subscribes this application to QueueBus events"
|
27
|
-
task :subscribe => [ :preload ] do
|
28
|
-
manager = ::QueueBus::TaskManager.new(true)
|
29
|
-
count = manager.subscribe!
|
30
|
-
raise "No subscriptions created" if count == 0
|
31
|
-
end
|
32
|
-
|
33
|
-
desc "Unsubscribes this application from QueueBus events"
|
34
|
-
task :unsubscribe => [ :preload ] do
|
35
|
-
require 'resque-bus'
|
36
|
-
manager = ::QueueBus::TaskManager.new(true)
|
37
|
-
count = manager.unsubscribe!
|
38
|
-
puts "No subscriptions unsubscribed" if count == 0
|
39
|
-
end
|
40
|
-
|
41
|
-
desc "Sets the queue to work the driver Use: `rake sidekiqbus:driver resque:work`"
|
42
|
-
task :driver => [ :preload ] do
|
43
|
-
ENV['QUEUES'] = ::QueueBus.incoming_queue
|
44
|
-
end
|
6
|
+
namespace :queuebus do
|
45
7
|
|
46
8
|
# Preload app files if this is Rails
|
47
9
|
task :preload do
|
48
10
|
require "sidekiq"
|
49
11
|
end
|
50
12
|
|
51
|
-
|
52
|
-
# examples to test out the system
|
53
|
-
namespace :example do
|
54
|
-
desc "Publishes events to example applications"
|
55
|
-
task :publish => [ "sidekiqbus:preload", "sidekiqbus:setup" ] do
|
56
|
-
which = ["one", "two", "three", "other"][rand(4)]
|
57
|
-
QueueBus.publish("event_#{which}", { "rand" => rand(99999)})
|
58
|
-
QueueBus.publish("event_all", { "rand" => rand(99999)})
|
59
|
-
QueueBus.publish("none_subscribed", { "rand" => rand(99999)})
|
60
|
-
puts "published event_#{which}, event_all, none_subscribed"
|
61
|
-
end
|
62
|
-
|
63
|
-
desc "Sets up an example config"
|
64
|
-
task :register => [ "sidekiqbus:preload"] do
|
65
|
-
QueueBus.dispatch("example") do
|
66
|
-
subscribe "event_one" do
|
67
|
-
puts "event1 happened"
|
68
|
-
end
|
69
|
-
|
70
|
-
subscribe "event_two" do
|
71
|
-
puts "event2 happened"
|
72
|
-
end
|
73
|
-
|
74
|
-
high "event_three" do
|
75
|
-
puts "event3 happened (high)"
|
76
|
-
end
|
77
|
-
|
78
|
-
low "event_.*" do |attributes|
|
79
|
-
puts "LOG ALL: #{attributes.inspect}"
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
desc "Subscribes this application to QueueBus example events"
|
85
|
-
task :subscribe => [ :register, "sidekiqbus:subscribe" ]
|
86
|
-
|
87
|
-
desc "Start a QueueBus example worker"
|
88
|
-
task :work => [ :register, "sidekiqbus:setup", "resque:work" ]
|
89
|
-
|
90
|
-
desc "Start a QueueBus example worker"
|
91
|
-
task :driver => [ :register, "sidekiqbus:driver", "resque:work" ]
|
92
|
-
end
|
93
13
|
end
|
data/lib/sidekiq_bus/version.rb
CHANGED
data/sidekiq-bus.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ["Brian Leonard"]
|
9
9
|
s.email = ["brian@bleonard.com"]
|
10
10
|
s.homepage = "https://github.com/queue-bus/sidekiq-bus"
|
11
|
-
s.summary = %q{A simple event bus on top of
|
12
|
-
s.description = %q{A simple event bus on top of
|
11
|
+
s.summary = %q{A simple event bus on top of Sidekiq}
|
12
|
+
s.description = %q{A simple event bus on top of Sidekiq. Publish and subscribe to events as they occur through a queue.}
|
13
13
|
|
14
14
|
s.rubyforge_project = "sidekiq-bus"
|
15
15
|
|
@@ -18,10 +18,13 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.add_dependency('queue-bus', '0.5.
|
21
|
+
s.add_dependency('queue-bus', '0.5.4')
|
22
22
|
s.add_dependency('sidekiq', ['>= 3.0.0', '< 4.0'])
|
23
23
|
|
24
24
|
s.add_development_dependency("rspec")
|
25
|
+
s.add_development_dependency("fakeredis")
|
26
|
+
s.add_development_dependency("redis-namespace")
|
27
|
+
s.add_development_dependency("pry")
|
25
28
|
s.add_development_dependency("timecop")
|
26
29
|
s.add_development_dependency("json_pure")
|
27
30
|
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'celluloid'
|
3
|
+
require 'sidekiq/scheduled'
|
4
|
+
|
5
|
+
describe "Sidekiq Integration" do
|
6
|
+
describe "Happy Path" do
|
7
|
+
before(:each) do
|
8
|
+
Sidekiq::Testing.fake!
|
9
|
+
QueueBus.dispatch("r1") do
|
10
|
+
subscribe "event_name" do |attributes|
|
11
|
+
QueueBus::Runner1.run(attributes)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
QueueBus::TaskManager.new(false).subscribe!
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should publish and receive" do
|
19
|
+
Sidekiq::Testing.fake!
|
20
|
+
QueueBus::Runner1.value.should == 0
|
21
|
+
|
22
|
+
QueueBus.publish("event_name", "ok" => true)
|
23
|
+
QueueBus::Runner1.value.should == 0
|
24
|
+
|
25
|
+
QueueBus::Worker.perform_one
|
26
|
+
|
27
|
+
QueueBus::Runner1.value.should == 0
|
28
|
+
|
29
|
+
QueueBus::Worker.perform_one
|
30
|
+
|
31
|
+
QueueBus::Runner1.value.should == 1
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should publish and receive" do
|
35
|
+
Sidekiq::Testing.inline!
|
36
|
+
QueueBus::Runner1.value.should == 0
|
37
|
+
|
38
|
+
QueueBus.publish("event_name", "ok" => true)
|
39
|
+
QueueBus::Runner1.value.should == 1
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "Delayed Publishing" do
|
45
|
+
before(:each) do
|
46
|
+
Timecop.freeze(now)
|
47
|
+
QueueBus.stub(:generate_uuid).and_return("idfhlkj")
|
48
|
+
end
|
49
|
+
after(:each) do
|
50
|
+
Timecop.return
|
51
|
+
end
|
52
|
+
let(:delayed_attrs) { {"bus_delayed_until" => future.to_i,
|
53
|
+
"bus_id" => "#{now.to_i}-idfhlkj",
|
54
|
+
"bus_app_hostname" => `hostname 2>&1`.strip.sub(/.local/,'')} }
|
55
|
+
|
56
|
+
let(:bus_attrs) { delayed_attrs.merge({"bus_published_at" => worktime.to_i})}
|
57
|
+
let(:now) { Time.parse("01/01/2013 5:00")}
|
58
|
+
let(:future) { Time.at(now.to_i + 60) }
|
59
|
+
let(:worktime) {Time.at(future.to_i + 1)}
|
60
|
+
|
61
|
+
it "should add it to Redis" do
|
62
|
+
hash = {:one => 1, "two" => "here", "id" => 12 }
|
63
|
+
event_name = "event_name"
|
64
|
+
QueueBus.publish_at(future, event_name, hash)
|
65
|
+
|
66
|
+
val = QueueBus.redis { |redis| redis.zrange("schedule", 0, 1) }.first
|
67
|
+
|
68
|
+
hash = JSON.parse(val)
|
69
|
+
|
70
|
+
hash["class"].should == "QueueBus::Worker"
|
71
|
+
hash["args"].size.should == 1
|
72
|
+
JSON.parse(hash["args"].first).should == {"bus_class_proxy" => "QueueBus::Publisher", "bus_event_type"=>"event_name", "two"=>"here", "one"=>1, "id" => 12}.merge(delayed_attrs)
|
73
|
+
hash["queue"].should == "bus_incoming"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should move it to the real queue when processing" do
|
77
|
+
hash = {:one => 1, "two" => "here", "id" => 12 }
|
78
|
+
event_name = "event_name"
|
79
|
+
|
80
|
+
val = QueueBus.redis { |redis| redis.lpop("queue:bus_incoming") }
|
81
|
+
val.should == nil
|
82
|
+
|
83
|
+
QueueBus.publish_at(future, event_name, hash)
|
84
|
+
|
85
|
+
val = QueueBus.redis { |redis| redis.lpop("queue:bus_incoming") }
|
86
|
+
val.should == nil # nothing really added
|
87
|
+
|
88
|
+
Sidekiq::Scheduled::Poller.new.poll
|
89
|
+
|
90
|
+
val = QueueBus.redis { |redis| redis.lpop("queue:bus_incoming") }
|
91
|
+
val.should == nil # nothing added yet
|
92
|
+
|
93
|
+
# process scheduler in future
|
94
|
+
Timecop.freeze(worktime) do
|
95
|
+
Sidekiq::Scheduled::Poller.new.poll
|
96
|
+
val = QueueBus.redis { |redis| redis.lpop("queue:bus_incoming") }
|
97
|
+
hash = JSON.parse(val)
|
98
|
+
hash["class"].should == "QueueBus::Worker"
|
99
|
+
hash["args"].size.should == 1
|
100
|
+
JSON.parse(hash["args"].first).should == {"bus_class_proxy" => "QueueBus::Publisher", "bus_event_type"=>"event_name", "two"=>"here", "one"=>1, "id" => 12}.merge(delayed_attrs)
|
101
|
+
|
102
|
+
QueueBus::Publisher.perform(JSON.parse(hash["args"].first))
|
103
|
+
|
104
|
+
val = QueueBus.redis { |redis| redis.lpop("queue:bus_incoming") }
|
105
|
+
hash = JSON.parse(val)
|
106
|
+
hash["class"].should == "QueueBus::Worker"
|
107
|
+
hash["args"].size.should == 1
|
108
|
+
JSON.parse(hash["args"].first).should == {"bus_class_proxy" => "QueueBus::Driver", "bus_event_type"=>"event_name", "two"=>"here", "one"=>1, "id" => 12}.merge(bus_attrs)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
end
|
data/spec/driver_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
require 'timecop'
|
2
2
|
require 'queue-bus'
|
3
3
|
require 'adapter/support'
|
4
|
+
require 'pry'
|
4
5
|
|
5
6
|
reset_test_adapter
|
6
7
|
|
8
|
+
require 'fakeredis'
|
9
|
+
Sidekiq.redis = ConnectionPool.new { Redis.new(driver: Redis::Connection::Memory) }
|
10
|
+
|
11
|
+
require 'sidekiq/testing'
|
12
|
+
|
7
13
|
module QueueBus
|
8
14
|
class Runner
|
9
15
|
def self.value
|
@@ -47,6 +53,11 @@ def test_list(*args)
|
|
47
53
|
end
|
48
54
|
|
49
55
|
RSpec.configure do |config|
|
56
|
+
|
57
|
+
config.run_all_when_everything_filtered = true
|
58
|
+
config.filter_run focus: true
|
59
|
+
config.alias_example_to :fit, focus: true
|
60
|
+
|
50
61
|
config.mock_with :rspec do |c|
|
51
62
|
c.syntax = :should
|
52
63
|
end
|
@@ -56,6 +67,7 @@ RSpec.configure do |config|
|
|
56
67
|
|
57
68
|
config.before(:each) do
|
58
69
|
reset_test_adapter
|
70
|
+
Sidekiq::Testing.disable!
|
59
71
|
end
|
60
72
|
config.after(:each) do
|
61
73
|
begin
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-bus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Leonard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: queue-bus
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.5.
|
19
|
+
version: 0.5.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.5.
|
26
|
+
version: 0.5.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sidekiq
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,6 +58,48 @@ dependencies:
|
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: fakeredis
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: redis-namespace
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: pry
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
61
103
|
- !ruby/object:Gem::Dependency
|
62
104
|
name: timecop
|
63
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,7 +128,7 @@ dependencies:
|
|
86
128
|
- - ">="
|
87
129
|
- !ruby/object:Gem::Version
|
88
130
|
version: '0'
|
89
|
-
description: A simple event bus on top of
|
131
|
+
description: A simple event bus on top of Sidekiq. Publish and subscribe to events
|
90
132
|
as they occur through a queue.
|
91
133
|
email:
|
92
134
|
- brian@bleonard.com
|
@@ -97,6 +139,8 @@ files:
|
|
97
139
|
- ".gitignore"
|
98
140
|
- ".rbenv-version"
|
99
141
|
- ".rspec"
|
142
|
+
- ".ruby-gemset"
|
143
|
+
- ".ruby-version"
|
100
144
|
- Gemfile
|
101
145
|
- MIT-LICENSE
|
102
146
|
- README.mdown
|
@@ -106,6 +150,7 @@ files:
|
|
106
150
|
- lib/sidekiq_bus/tasks.rb
|
107
151
|
- lib/sidekiq_bus/version.rb
|
108
152
|
- sidekiq-bus.gemspec
|
153
|
+
- spec/adapter/integration_spec.rb
|
109
154
|
- spec/adapter/support.rb
|
110
155
|
- spec/adapter_spec.rb
|
111
156
|
- spec/application_spec.rb
|
@@ -145,8 +190,9 @@ rubyforge_project: sidekiq-bus
|
|
145
190
|
rubygems_version: 2.2.2
|
146
191
|
signing_key:
|
147
192
|
specification_version: 4
|
148
|
-
summary: A simple event bus on top of
|
193
|
+
summary: A simple event bus on top of Sidekiq
|
149
194
|
test_files:
|
195
|
+
- spec/adapter/integration_spec.rb
|
150
196
|
- spec/adapter/support.rb
|
151
197
|
- spec/adapter_spec.rb
|
152
198
|
- spec/application_spec.rb
|