queue-bus 0.5.2 → 0.5.3
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/driver.rb +1 -2
- data/lib/queue_bus/local.rb +3 -4
- data/lib/queue_bus/publisher.rb +2 -10
- data/lib/queue_bus/publishing.rb +6 -5
- data/lib/queue_bus/version.rb +1 -1
- data/spec/driver_spec.rb +1 -1
- data/spec/subscriber_spec.rb +1 -1
- metadata +2 -2
data/lib/queue_bus/driver.rb
CHANGED
@@ -26,8 +26,7 @@ module QueueBus
|
|
26
26
|
"bus_rider_sub_key" => sub.key,
|
27
27
|
"bus_rider_class_name" => sub.class_name}
|
28
28
|
bus_attr = bus_attr.merge(attributes || {})
|
29
|
-
|
30
|
-
::QueueBus.enqueue_to(sub.queue_name, ::QueueBus::Worker, bus_attr)
|
29
|
+
::QueueBus.enqueue_to(sub.queue_name, sub.class_name, bus_attr)
|
31
30
|
end
|
32
31
|
end
|
33
32
|
end
|
data/lib/queue_bus/local.rb
CHANGED
@@ -3,7 +3,7 @@ module QueueBus
|
|
3
3
|
class Local
|
4
4
|
|
5
5
|
class << self
|
6
|
-
def
|
6
|
+
def publish(attributes = {})
|
7
7
|
if ::QueueBus.local_mode == :suppress
|
8
8
|
::QueueBus.log_worker("Suppressed: #{attributes.inspect}")
|
9
9
|
return # not doing anything
|
@@ -17,11 +17,10 @@ module QueueBus
|
|
17
17
|
"bus_rider_queue" => sub.queue_name,
|
18
18
|
"bus_rider_app_key" => sub.app_key,
|
19
19
|
"bus_rider_sub_key" => sub.key,
|
20
|
-
"bus_rider_class_name" => sub.class_name
|
21
|
-
"bus_class_proxy" => sub.class_name}
|
20
|
+
"bus_rider_class_name" => sub.class_name}
|
22
21
|
to_publish = bus_attr.merge(attributes || {})
|
23
22
|
if ::QueueBus.local_mode == :standalone
|
24
|
-
::QueueBus.enqueue_to(sub.queue_name,
|
23
|
+
::QueueBus.enqueue_to(sub.queue_name, sub.class_name, bus_attr.merge(attributes || {}))
|
25
24
|
else # defaults to inline mode
|
26
25
|
sub.execute!(to_publish)
|
27
26
|
end
|
data/lib/queue_bus/publisher.rb
CHANGED
@@ -3,16 +3,8 @@ module QueueBus
|
|
3
3
|
class Publisher
|
4
4
|
|
5
5
|
class << self
|
6
|
-
def perform(
|
7
|
-
|
8
|
-
if args.size > 1
|
9
|
-
# handles older arguments
|
10
|
-
event_type = args.first
|
11
|
-
attributes = args.last
|
12
|
-
else
|
13
|
-
attributes = args.first
|
14
|
-
event_type = attributes["bus_event_type"]
|
15
|
-
end
|
6
|
+
def perform(attributes)
|
7
|
+
event_type = attributes["bus_event_type"]
|
16
8
|
::QueueBus.log_worker("Publisher running: #{event_type} - #{attributes.inspect}")
|
17
9
|
::QueueBus.publish(event_type, attributes)
|
18
10
|
end
|
data/lib/queue_bus/publishing.rb
CHANGED
@@ -48,13 +48,12 @@ module QueueBus
|
|
48
48
|
|
49
49
|
def publish(event_type, attributes = {})
|
50
50
|
to_publish = publish_metadata(event_type, attributes)
|
51
|
-
to_publish["bus_class_proxy"] = ::QueueBus::Driver.name.to_s
|
52
51
|
|
53
52
|
::QueueBus.log_application("Event published: #{event_type} #{to_publish.inspect}")
|
54
53
|
if local_mode
|
55
|
-
::QueueBus::Local.
|
54
|
+
::QueueBus::Local.publish(to_publish) # TODO: use different adapters
|
56
55
|
else
|
57
|
-
enqueue_to(::QueueBus.incoming_queue, ::QueueBus::
|
56
|
+
enqueue_to(::QueueBus.incoming_queue, ::QueueBus::Driver, to_publish)
|
58
57
|
end
|
59
58
|
end
|
60
59
|
|
@@ -68,8 +67,10 @@ module QueueBus
|
|
68
67
|
delayed_enqueue_to(timestamp_or_epoch.to_i, incoming_queue, ::QueueBus::Worker, to_publish)
|
69
68
|
end
|
70
69
|
|
71
|
-
def enqueue_to(queue_name,
|
72
|
-
|
70
|
+
def enqueue_to(queue_name, class_name, hash)
|
71
|
+
class_name = class_name.name if class_name.is_a?(Class)
|
72
|
+
hash = hash.merge("bus_class_proxy" => class_name.to_s)
|
73
|
+
::QueueBus.adapter.enqueue(queue_name, ::QueueBus::Worker, ::QueueBus::Util.encode(hash || {}))
|
73
74
|
end
|
74
75
|
|
75
76
|
def delayed_enqueue_to(epoch_seconds, queue_name, klass, hash)
|
data/lib/queue_bus/version.rb
CHANGED
data/spec/driver_spec.rb
CHANGED
data/spec/subscriber_spec.rb
CHANGED
@@ -199,7 +199,7 @@ require 'spec_helper'
|
|
199
199
|
pop1 = JSON.parse(QueueBus.redis { |redis| redis.lpop("queue:myqueue") })
|
200
200
|
pop2 = JSON.parse(QueueBus.redis { |redis| redis.lpop("queue:myqueue") })
|
201
201
|
|
202
|
-
if pop1["args"].first["bus_rider_sub_key"] == "SubscriberTest1.thing_filter"
|
202
|
+
if JSON.parse(pop1["args"].first)["bus_rider_sub_key"] == "SubscriberTest1.thing_filter"
|
203
203
|
hash1 = pop1
|
204
204
|
hash2 = pop2
|
205
205
|
else
|
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.3
|
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-
|
12
|
+
date: 2015-02-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|