queue-bus 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- bus_attr["bus_class_proxy"] = sub.class_name
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
@@ -3,7 +3,7 @@ module QueueBus
3
3
  class Local
4
4
 
5
5
  class << self
6
- def perform(attributes = {})
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, ::QueueBus::Worker, bus_attr.merge(attributes || {}))
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
@@ -3,16 +3,8 @@ module QueueBus
3
3
  class Publisher
4
4
 
5
5
  class << self
6
- def perform(*args)
7
- # TODO: move this to just resquebus for fallback
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
@@ -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.perform(to_publish)
54
+ ::QueueBus::Local.publish(to_publish) # TODO: use different adapters
56
55
  else
57
- enqueue_to(::QueueBus.incoming_queue, ::QueueBus::Worker, to_publish)
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, klass, hash)
72
- ::QueueBus.adapter.enqueue(queue_name, klass, ::QueueBus::Util.encode(hash || {}))
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)
@@ -1,3 +1,3 @@
1
1
  module QueueBus
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
data/spec/driver_spec.rb CHANGED
@@ -95,7 +95,7 @@ module QueueBus
95
95
  hash1 = pop2
96
96
  hash2 = pop1
97
97
  args1 = pargs2
98
- args2 = pargs2
98
+ args2 = pargs1
99
99
  end
100
100
 
101
101
  hash1["class"].should == "QueueBus::Worker"
@@ -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.2
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-01-21 00:00:00.000000000 Z
12
+ date: 2015-02-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json