philotic 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 47b970f227032a30e680562ee09c41d2ba6f5a46
4
- data.tar.gz: bbc36d33ee8bdd0c09b7b9a2af4a0b3dfe991f5d
5
- SHA512:
6
- metadata.gz: a368f139afcdfa7e9516653cd8f9455ec7d6b24bc33eef603b129a5366f25b2e1fb9ac52f70d85dadbc35995b4b201678ba22046edc4da32cbf98aa5b9f97e08
7
- data.tar.gz: ff47fae4fb59c8e39c4fe73974295780765e6239e7c9d6f25e2c6a296ea2149add58f8d628ce9eff0d207d0068899686e0a307983db0c1e52ba569720d95f958
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dd9e68a219e5e261cff5c93874204ee23ac50eff
4
+ data.tar.gz: 76474a8e73d1306e885161c8639043b1ad80d15f
5
+ SHA512:
6
+ metadata.gz: 1cd304f11017c7e646a0ce22d7bf620613cdb73a5fff3e0cfc2e78d2c63750dd7ed28ec8cf216f59f273eeda92a77881c94894d9a0e07edbee49c37958be336c
7
+ data.tar.gz: c7db1f0ac754a5e76c0266957443b13cc1e25e52f9ce2aec2fe47723465881262214ac67342ee8cc5aa18e4f330cd1ab6cb843ccaca92c44efdc5766439a36d4
@@ -18,3 +18,5 @@ notifications:
18
18
  hipchat:
19
19
  rooms:
20
20
  secure: akLY832/pt0+9Y2TFKpzW08bagPMY//AcQJ5JGzc0yd3hZbXTlkW4S8bMEclBeHBqLGCV6vaWeN90PiYwIBs4IWlxopPAop4BEWeqRvD8+B4fxarXYwejt54vH3v4iCnHhSNBpFJDbykyfL0f0g9fhvM48eHzhBXTxPZfpQ9nXs=
21
+ template:
22
+ - '%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}'
data/README.md CHANGED
@@ -14,24 +14,26 @@ Check out the [examples](https://github.com/nkeyes/philotic/tree/master/examples
14
14
  require 'philotic'
15
15
  require 'awesome_print'
16
16
 
17
+ philotic = Philotic::Connection.new
18
+
17
19
  # override the message return handler
18
- Philotic::Config.message_return_handler = lambda do |basic_return, metadata, message|
19
- Philotic.logger.warn "Message returned. reply_text: #{basic_return.reply_text}"
20
+ philotic.config.message_return_handler = lambda do |basic_return, metadata, message|
21
+ philotic.logger.warn "Message returned. reply_text: #{basic_return.reply_text}"
20
22
  end
21
23
 
22
- Philotic::Subscriber.subscribe(header_key: 'header_1') do |metadata, message|
24
+ philotic.subscriber.subscribe(header_key: 'header_1') do |metadata, message|
23
25
  ap message[:attributes]
24
26
  end
25
27
 
26
28
  # normally we'd do:
27
29
  #
28
- # Philotic::Subscriber.endure
30
+ # philotic.subscriber.endure
29
31
  #
30
32
  # to keep the parent thread alive while the subscribers do their thing
31
33
  # but this infinite publish loop takes care of that
32
34
  loop do
33
- Philotic::Event.publish({header_key: "header_#{[1, 2].sample}"}, {payload_key: 'payload_value'})
34
-
35
+ event = Philotic::Event.new({header_key: "header_#{[1, 2].sample}"}, {payload_key: 'payload_value'})
36
+ philotic.publish event
35
37
  # only send a message every two seconds so we can see whats going on
36
38
  sleep 2
37
39
  end
@@ -4,10 +4,13 @@ $stdout.sync = true
4
4
 
5
5
  require 'philotic'
6
6
 
7
+ philotic = Philotic::Connection.new
8
+
7
9
  # explicitly create named queues for this example
8
- # ENV['PHILOTIC_INITIALIZE_NAMED_QUEUE'] must equal 'true' to run Philotic.initialize_named_queue!
9
- ENV['PHILOTIC_INITIALIZE_NAMED_QUEUE'] = 'true'
10
- Philotic.initialize_named_queue!('male_queue', bindings: [{:'x-match' => 'all', gender: :M, available: true}])
11
- Philotic.initialize_named_queue!('female_queue', bindings: [{:'x-match' => 'all', gender: :F, available: true}])
12
- Philotic.initialize_named_queue!('test_queue', bindings: [{ :'x-match' => 'any', gender: :M, available: true }])
13
- Philotic.initialize_named_queue!('flaky_queue', bindings: [{ :'x-match' => 'any', gender: :M, available: true }])
10
+ # philotic.config.initialize_named_queues must be truthy to run Philotic.initialize_named_queue!
11
+ philotic.config.initialize_named_queues = true
12
+
13
+ philotic.initialize_named_queue!('male_queue', bindings: [{:'x-match' => 'all', gender: :M, available: true}])
14
+ philotic.initialize_named_queue!('female_queue', bindings: [{:'x-match' => 'all', gender: :F, available: true}])
15
+ philotic.initialize_named_queue!('test_queue', bindings: [{ :'x-match' => 'any', gender: :M, available: true }])
16
+ philotic.initialize_named_queue!('flaky_queue', bindings: [{ :'x-match' => 'any', gender: :M, available: true }])
@@ -7,5 +7,5 @@ require 'rake'
7
7
 
8
8
  require 'philotic/tasks'
9
9
  # equivelant of:
10
- # rake eb:init_queues[examples/creating_named_queues/philotic_named_queues.yml]
11
- Rake::Task["eb:init_queues"].invoke(File.join(File.dirname(__FILE__), ".", "philotic_named_queues.yml"))
10
+ # rake philotic:init_queues[examples/creating_named_queues/philotic_queues.yml]
11
+ Rake::Task['philotic:init_queues'].invoke(File.join(File.dirname(__FILE__), 'philotic_queues.yml'))
@@ -5,7 +5,9 @@ $stdout.sync = true
5
5
  require 'philotic'
6
6
  require 'philotic/dummy_event'
7
7
 
8
- Philotic.logger.level = Logger::WARN
8
+ @philotic = Philotic::Connection.new
9
+
10
+ @philotic.publisher.logger.level = Logger::WARN
9
11
 
10
12
  @event = Philotic::DummyEvent.new
11
13
 
@@ -24,7 +26,7 @@ def send_message number
24
26
  @event.gender = [:F, :M].sample
25
27
  @event.message = "Message #{number}: Hey #{@event.gender == :M ? 'dude' : 'dudette'}"
26
28
 
27
- @event.publish
29
+ @philotic.publish @event
28
30
 
29
31
  end
30
32
 
@@ -5,24 +5,26 @@ $stdout.sync = true
5
5
  require 'philotic'
6
6
  require 'awesome_print'
7
7
 
8
+ philotic = Philotic::Connection.new
9
+
8
10
  # override the message return handler
9
- Philotic::Config.message_return_handler = lambda do |basic_return, metadata, message|
10
- Philotic.logger.warn "Message returned. reply_text: #{basic_return.reply_text}"
11
+ philotic.config.message_return_handler = lambda do |basic_return, metadata, message|
12
+ philotic.logger.warn "Message returned. reply_text: #{basic_return.reply_text}"
11
13
  end
12
14
 
13
- Philotic::Subscriber.subscribe(header_key: 'header_1') do |metadata, message|
15
+ philotic.subscriber.subscribe(header_key: 'header_1') do |metadata, message|
14
16
  ap message[:attributes]
15
17
  end
16
18
 
17
19
  # normally we'd do:
18
20
  #
19
- # Philotic::Subscriber.endure
21
+ # philotic.subscriber.endure
20
22
  #
21
23
  # to keep the parent thread alive while the subscribers do their thing
22
24
  # but this infinite publish loop takes care of that
23
25
  loop do
24
- Philotic::Event.publish({header_key: "header_#{[1, 2].sample}"}, {payload_key: 'payload_value'})
25
-
26
+ event = Philotic::Event.new({header_key: "header_#{[1, 2].sample}"}, {payload_key: 'payload_value'})
27
+ philotic.publish event
26
28
  # only send a message every two seconds so we can see whats going on
27
29
  sleep 2
28
30
  end
@@ -5,21 +5,24 @@ $stdout.sync = true
5
5
  require 'philotic'
6
6
  require 'awesome_print'
7
7
 
8
+ philotic = Philotic::Connection.new
9
+
10
+
8
11
  # sometimes ack
9
- Philotic::Subscriber.subscribe('flaky_queue', ack: true) do |metadata, message|
12
+ philotic.subscriber.subscribe('flaky_queue', ack: true) do |metadata, message|
10
13
  ap message[:attributes]
11
- [true, false].sample ? Philotic::Subscriber.acknowledge(message) : Philotic::Subscriber.reject(message)
14
+ [true, false].sample ? philotic.subscriber.acknowledge(message) : philotic.subscriber.reject(message)
12
15
  end
13
16
 
14
17
  # always ack
15
- Philotic::Subscriber.subscribe('flaky_queue', ack: true) do |metadata, message|
18
+ philotic.subscriber.subscribe('flaky_queue', ack: true) do |metadata, message|
16
19
  ap message[:attributes]
17
- Philotic::Subscriber.acknowledge(message, true)
20
+ philotic.subscriber.acknowledge(message, true)
18
21
  end
19
22
 
20
23
  # always reject
21
- Philotic::Subscriber.subscribe('flaky_queue', ack: true) do |metadata, message|
24
+ philotic.subscriber.subscribe('flaky_queue', ack: true) do |metadata, message|
22
25
  ap message[:attributes]
23
- Philotic::Subscriber.reject message
26
+ philotic.subscriber.reject message
24
27
  end
25
- Philotic::Subscriber.endure
28
+ philotic.subscriber.endure
@@ -5,11 +5,13 @@ $stdout.sync = true
5
5
  require 'philotic'
6
6
  require 'awesome_print'
7
7
 
8
- Philotic::Config.load_file(File.join(File.dirname(__FILE__), '../../', 'philotic.yml.example'))
8
+ philotic = Philotic::Connection.new
9
9
 
10
+ philotic.config.load_file(File.join(File.dirname(__FILE__), '../../', 'philotic.yml.example'))
10
11
 
11
- Philotic::Subscriber.subscribe(philotic_firehose: true) do |metadata, message|
12
+
13
+ philotic.subscriber.subscribe(philotic_firehose: true) do |metadata, message|
12
14
  ap message[:attributes]
13
15
  end
14
16
 
15
- Philotic::Subscriber.endure
17
+ philotic.subscriber.endure
@@ -4,15 +4,17 @@ $stdout.sync = true
4
4
 
5
5
  require 'philotic'
6
6
  require 'awesome_print'
7
+ philotic = Philotic::Connection.new
7
8
 
8
- Philotic::Config.load_file(File.join(File.dirname(__FILE__), '../../', 'philotic.yml.example'))
9
9
 
10
- Philotic::Subscriber.subscribe('female_queue') do |metadata, message|
10
+ philotic.config.load_file(File.join(File.dirname(__FILE__), '../../', 'philotic.yml.example'))
11
+
12
+ philotic.subscriber.subscribe('female_queue') do |metadata, message|
11
13
  ap message[:attributes]
12
14
  end
13
15
 
14
- Philotic::Subscriber.subscribe('male_queue') do |metadata, message|
16
+ philotic.subscriber.subscribe('male_queue') do |metadata, message|
15
17
  ap message[:attributes]
16
18
  end
17
19
 
18
- Philotic::Subscriber.endure
20
+ philotic.subscriber.endure
@@ -5,9 +5,10 @@ $stdout.sync = true
5
5
  require 'philotic'
6
6
  require 'awesome_print'
7
7
 
8
+ philotic = Philotic::Connection.new
8
9
 
9
- Philotic::Subscriber.subscribe('test_queue') do |metadata, message|
10
+ philotic.subscriber.subscribe('test_queue') do |metadata, message|
10
11
  ap message[:attributes]
11
12
  end
12
13
 
13
- Philotic::Subscriber.endure
14
+ philotic.subscriber.endure
@@ -1,12 +1,11 @@
1
1
  require 'active_support/all'
2
2
  require 'pathname'
3
- require 'logger'
4
3
 
5
4
  require 'philotic/constants'
5
+ require 'philotic/connection'
6
+
6
7
 
7
8
  module Philotic
8
- mattr_accessor :logger
9
- mattr_accessor :log_event_handler
10
9
 
11
10
  def self.root
12
11
  ::Pathname.new File.expand_path('../../', __FILE__)
@@ -16,92 +15,12 @@ module Philotic
16
15
  ENV['SERVICE_ENV'] || 'development'
17
16
  end
18
17
 
19
- def self.exchange
20
- Philotic::Connection.exchange
21
- end
22
-
23
- def self.initialize_named_queue!(queue_name, config)
24
- raise 'Philotic::Config.initialize_named_queues must be true to run Philotic.initialize_named_queue!' unless Philotic::Config.initialize_named_queues
25
-
26
- Philotic.connect!
27
- queue_exists = Philotic::Connection.connection.queue_exists? queue_name
28
-
29
- should_delete_queue = queue_exists && Philotic::Config.delete_existing_queues
30
- should_create_queue = !queue_exists || Philotic::Config.delete_existing_queues
31
-
32
- if should_delete_queue
33
- Philotic::Connection.channel.queue(queue_name, passive: true).delete
34
- Philotic.logger.info "deleted old queue. queue: #{queue_name}"
35
- end
36
-
37
- if should_create_queue
38
- config = config.deep_symbolize_keys
39
- queue = queue_from_config(queue_name, config)
40
- bind_queue(queue, config)
41
- else
42
- Philotic.logger.warn "Queue #{queue_name} not created; it already exists. Philotic::Config.delete_existing_queues must be true to override."
43
- end
44
- end
45
-
46
- def self.bind_queue(queue, config)
47
- queue_exchange = exchange_from_config(config)
48
- bindings = config[:bindings]
49
- bindings.each do |arguments|
50
- queue.bind(queue_exchange, {arguments: arguments})
51
- Philotic.logger.info "Added binding to queue. queue: #{queue.name} binding: #{arguments}"
52
- end
53
-
54
- Philotic.logger.info "Finished adding bindings to queue. queue: #{queue.name}"
55
- end
56
-
57
- def self.exchange_from_config(config)
58
- config[:exchange] ? Philotic::Connection.channel.headers(config[:exchange], durable: true) : exchange
59
- end
60
-
61
- def self.queue_from_config(queue_name, config)
62
- queue_options = DEFAULT_NAMED_QUEUE_OPTIONS.dup
63
- queue_options.merge!(config[:options] || {})
64
-
65
- Philotic::Connection.channel.queue(queue_name, queue_options).tap do
66
- Philotic.logger.info "Created queue. queue:#{queue_name}"
67
- end
68
- end
69
-
70
- def self.logger
71
- @@logger ||= init_logger
72
- end
73
-
74
- def self.init_logger
75
- Logger.new(STDOUT)
76
- end
77
-
78
- def self.on_publish_event(&block)
79
- @@log_event_handler = block
80
- end
81
-
82
- def self.log_event_published(severity, metadata, payload, message)
83
- if @@log_event_handler
84
- @@log_event_handler.call(severity, metadata, payload, message)
85
- else
86
- logger.send(severity, "#{message}; message_metadata:#{metadata}, payload:#{payload.to_json}")
87
- end
88
- end
89
-
90
- def self.connected?
91
- Philotic::Connection.connected?
92
- end
93
-
94
- def self.connect!
95
- Philotic::Connection.connect!
96
- end
97
-
98
- def self.close
99
- Philotic::Connection.close
18
+ def self.connection
19
+ @connection ||= Philotic::Connection.new
100
20
  end
101
21
  end
102
22
 
103
23
  require 'philotic/version'
104
- require 'philotic/connection'
105
24
  require 'philotic/config'
106
25
  require 'philotic/routable'
107
26
  require 'philotic/event'
@@ -4,19 +4,20 @@ require 'singleton'
4
4
  require 'forwardable'
5
5
  require 'cgi'
6
6
  require 'bunny/session'
7
+ require 'logger'
7
8
 
8
9
  module Philotic
9
- module Config
10
- extend self
10
+ class Config
11
11
 
12
12
  ENV_PREFIX = 'PHILOTIC'
13
13
 
14
14
  DEFAULT_DISABLE_PUBLISH = false
15
15
  DEFAULT_INITIALIZE_NAMED_QUEUES = false
16
16
  DEFAULT_DELETE_EXISTING_QUEUES = false
17
- DEFAULT_RABBIT_SCHEME = 'amqps'
17
+ DEFAULT_LOG_LEVEL = Logger::DEBUG
18
+ DEFAULT_RABBIT_SCHEME = 'amqp'
18
19
  DEFAULT_RABBIT_HOST = 'localhost'
19
- DEFAULT_RABBIT_PORT = 5671
20
+ DEFAULT_RABBIT_PORT = 5672
20
21
  DEFAULT_RABBIT_USER = 'guest'
21
22
  DEFAULT_RABBIT_PASSWORD = 'guest'
22
23
  DEFAULT_RABBIT_VHOST = '%2f' # '/'
@@ -39,6 +40,17 @@ module Philotic
39
40
  DEFAULT_TIMESTAMP = nil
40
41
  DEFAULT_EXPIRATION = nil
41
42
 
43
+ attr_accessor :connection
44
+
45
+ def initialize(connection, config={})
46
+ load_config config
47
+ @connection = connection
48
+ end
49
+
50
+ def logger
51
+ connection.logger
52
+ end
53
+
42
54
  def defaults
43
55
  @defaults ||= Hash[Config.constants.select { |c| c.to_s.start_with? 'DEFAULT_' }.collect do |c|
44
56
  key = c.slice(8..-1).downcase.to_sym
@@ -62,27 +74,30 @@ module Philotic
62
74
  end
63
75
  end
64
76
 
77
+ def log_level
78
+ @log_level ||= defaults[:log_level].to_i
79
+ end
65
80
  attr_writer :connection_failed_handler, :connection_loss_handler, :message_return_handler
66
81
 
67
82
  def connection_failed_handler
68
83
  @connection_failed_handler ||= lambda do |settings|
69
- Philotic.logger.error "RabbitMQ connection failure; host:#{rabbit_host}"
84
+ logger.error "RabbitMQ connection failure; host:#{rabbit_host}"
70
85
  end
71
86
  end
72
87
 
73
88
  def connection_loss_handler
74
89
  @connection_loss_handler ||= lambda do |conn, settings|
75
- Philotic.logger.warn "RabbitMQ connection loss; host:#{rabbit_host}"; conn.reconnect(false, 2)
90
+ logger.warn "RabbitMQ connection loss; host:#{rabbit_host}"; conn.reconnect(false, 2)
76
91
  end
77
92
  end
78
93
 
79
94
  def message_return_handler
80
95
  @message_return_handler ||= lambda do |basic_return, metadata, payload|
81
- Philotic.logger.warn "Philotic message #{JSON.parse payload} was returned! reply_code = #{basic_return.reply_code}, reply_text = #{basic_return.reply_text} headers = #{metadata[:headers]}"
96
+ logger.warn "Philotic message #{JSON.parse payload} was returned! reply_code = #{basic_return.reply_code}, reply_text = #{basic_return.reply_text} headers = #{metadata[:headers]}"
82
97
  end
83
98
  end
84
99
 
85
- def self.parse_rabbit_uri
100
+ def parse_rabbit_uri
86
101
  settings = Bunny::Session.parse_uri(@rabbit_url || defaults[:rabbit_url])
87
102
  settings[:password] = settings.delete(:pass)
88
103
 
@@ -91,21 +106,19 @@ module Philotic
91
106
  current_value = send("rabbit_#{setting}")
92
107
 
93
108
  # only use the value from the URI if the existing value is nil or the default
94
- if settings[setting] && [const_get("default_rabbit_#{setting}".upcase), nil].include?(current_value)
109
+ if settings[setting] && [self.class.const_get("default_rabbit_#{setting}".upcase), nil].include?(current_value)
95
110
  send("rabbit_#{setting}=", settings[setting])
96
111
  end
97
112
  end
98
113
 
99
114
  end
100
115
 
101
- def self.rabbit_url
102
- self.parse_rabbit_uri
116
+ def rabbit_url
117
+ parse_rabbit_uri
103
118
  "#{rabbit_scheme}://#{rabbit_user}:#{rabbit_password}@#{rabbit_host}:#{rabbit_port}/#{CGI.escape rabbit_vhost}"
104
119
  end
105
120
 
106
- def load(config)
107
- Philotic.logger # ensure the logger can be created, so we crash early if it can't
108
-
121
+ def load_config(config)
109
122
  config.each do |k, v|
110
123
  mutator = "#{k}="
111
124
  send(mutator, v) if respond_to? mutator
@@ -1,16 +1,28 @@
1
- require 'singleton'
2
1
  require 'json'
3
2
  require 'bunny'
3
+ require 'logger'
4
4
 
5
5
  require 'philotic/config'
6
+ require 'philotic/publisher'
7
+ require 'philotic/subscriber'
6
8
 
7
9
  module Philotic
8
- module Connection
9
- extend self
10
+ class Connection
10
11
  attr_reader :connection
12
+ attr_accessor :logger
13
+
14
+ attr_writer :publisher, :subscriber
15
+
16
+ def publisher
17
+ @publisher ||= Philotic::Publisher.new self
18
+ end
19
+
20
+ def subscriber
21
+ @subscriber ||= Philotic::Subscriber.new self
22
+ end
11
23
 
12
24
  def config
13
- Philotic::Config
25
+ @config ||= Philotic::Config.new self
14
26
  end
15
27
 
16
28
  def connect!
@@ -19,11 +31,11 @@ module Philotic
19
31
  start_connection!
20
32
 
21
33
  if connected?
22
- Philotic.logger.info "connected to RabbitMQ: #{config.rabbit_host}:#{config.rabbit_port}"
34
+ logger.info "connected to RabbitMQ: #{config.rabbit_host}:#{config.rabbit_port}"
23
35
  set_exchange_return_handler!
24
36
  true
25
37
  else
26
- Philotic.logger.error "failed connected to RabbitMQ; host:#{config.rabbit_host}"
38
+ logger.error "failed connected to RabbitMQ; host:#{config.rabbit_host}"
27
39
  false
28
40
  end
29
41
  end
@@ -42,9 +54,9 @@ module Philotic
42
54
  end
43
55
 
44
56
  def close
45
- Philotic.logger.info "closing connection to RabbitMQ; host:#{config.rabbit_host}"
57
+ logger.info "closing connection to RabbitMQ; host:#{config.rabbit_host}"
46
58
  connection.close if connected?
47
- @channel = nil
59
+ @channel = nil
48
60
  @exchange = nil
49
61
  end
50
62
 
@@ -65,5 +77,64 @@ module Philotic
65
77
  config.message_return_handler.call(basic_return, metadata, payload)
66
78
  end
67
79
  end
80
+
81
+ def initialize_named_queue!(queue_name, config)
82
+ raise 'Philotic.config.initialize_named_queues must be true to run Philotic.initialize_named_queue!' unless self.config.initialize_named_queues
83
+
84
+ connect!
85
+ queue_exists = connection.queue_exists? queue_name
86
+
87
+ should_delete_queue = queue_exists && self.config.delete_existing_queues
88
+ should_create_queue = !queue_exists || self.config.delete_existing_queues
89
+
90
+ if should_delete_queue
91
+ channel.queue(queue_name, passive: true).delete
92
+ logger.info "deleted old queue. queue: #{queue_name}"
93
+ end
94
+
95
+ if should_create_queue
96
+ config = config.deep_symbolize_keys
97
+ queue = queue_from_config(queue_name, config)
98
+ bind_queue(queue, config)
99
+ else
100
+ logger.warn "Queue #{queue_name} not created; it already exists. self.config.delete_existing_queues must be true to override."
101
+ end
102
+ end
103
+
104
+ def bind_queue(queue, config)
105
+ queue_exchange = exchange_from_config(config)
106
+ bindings = config[:bindings]
107
+ bindings.each do |arguments|
108
+ queue.bind(queue_exchange, {arguments: arguments})
109
+ logger.info "Added binding to queue. queue: #{queue.name} binding: #{arguments}"
110
+ end
111
+
112
+ logger.info "Finished adding bindings to queue. queue: #{queue.name}"
113
+ end
114
+
115
+ def exchange_from_config(config)
116
+ config[:exchange] ? channel.headers(config[:exchange], durable: true) : exchange
117
+ end
118
+
119
+ def queue_from_config(queue_name, config)
120
+ queue_options = DEFAULT_NAMED_QUEUE_OPTIONS.dup
121
+ queue_options.merge!(config[:options] || {})
122
+
123
+ channel.queue(queue_name, queue_options).tap do
124
+ logger.info "Created queue. queue:#{queue_name}"
125
+ end
126
+ end
127
+
128
+ def logger
129
+ unless @logger
130
+ @logger = Logger.new(STDOUT)
131
+ @logger.level = config.log_level
132
+ end
133
+ @logger
134
+ end
135
+
136
+ def publish(event)
137
+ publisher.publish(event)
138
+ end
68
139
  end
69
140
  end