Module: Cottontail::Consumer
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/cottontail/consumer.rb,
lib/cottontail/consumer/entity.rb,
lib/cottontail/consumer/session.rb,
lib/cottontail/consumer/launcher.rb,
lib/cottontail/consumer/collection.rb
Overview
Defined Under Namespace
Modules: ClassMethods
Classes: Collection, Entity, Launcher, Session
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
173
174
175
|
# File 'lib/cottontail/consumer.rb', line 173
def options
@options
end
|
Instance Method Details
#initialize(options = {}) ⇒ Object
175
176
177
178
179
180
181
182
183
184
185
186
|
# File 'lib/cottontail/consumer.rb', line 175
def initialize(options = {})
@options = options
run_callbacks :initialize do
@__running__ = false
@__launcher__ = Cottontail::Consumer::Launcher.new(self)
@__session__ = Cottontail::Consumer::Session.new(self)
end
logger.debug '[Cottontail] initialized'
end
|
#logger ⇒ Object
218
219
220
|
# File 'lib/cottontail/consumer.rb', line 218
def logger
config.get(:logger)
end
|
#running? ⇒ Boolean
206
207
208
|
# File 'lib/cottontail/consumer.rb', line 206
def running?
@__running__
end
|
#start(blocking = true) ⇒ Object
188
189
190
191
192
193
194
|
# File 'lib/cottontail/consumer.rb', line 188
def start(blocking = true)
logger.info '[Cottontail] starting up'
@__session__.start
@__running__ = true
@__launcher__.start if blocking
end
|
#stop ⇒ Object
196
197
198
199
200
201
202
203
204
|
# File 'lib/cottontail/consumer.rb', line 196
def stop
return unless running?
logger.info '[Cottontail] shutting down'
@__launcher__.stop
@__session__.stop
@__running__ = false
end
|
#subscribe(queue, options) ⇒ Object
211
212
213
214
215
|
# File 'lib/cottontail/consumer.rb', line 211
def subscribe(queue, options)
queue.subscribe(options) do |delivery_info, properties, payload|
consume(delivery_info, properties, payload)
end
end
|