Module: Tackle
- Defined in:
- lib/tackle.rb,
lib/tackle/rabbit.rb,
lib/tackle/worker.rb,
lib/tackle/version.rb,
lib/tackle/publisher.rb,
lib/tackle/delayed_retry.rb,
lib/tackle/tackle_logger.rb
Defined Under Namespace
Modules: TackleLogger
Classes: DelayedRetry, Publisher, Rabbit, Worker
Constant Summary
collapse
- VERSION =
"0.8.0"
Class Method Summary
collapse
Class Method Details
.publish(message, options = {}) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/tackle.rb', line 32
def self.publish(message, options = {})
exchange_name = options.fetch(:exchange)
routing_key = options.fetch(:routing_key)
amqp_url = options[:url] || "amqp://localhost:5672"
logger = options[:logger] || Logger.new(STDOUT)
publisher = Tackle::Publisher.new(exchange_name, routing_key, amqp_url, logger)
publisher.publish(message)
end
|
.subscribe(options = {}, &block) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/tackle.rb', line 7
def self.subscribe(options = {}, &block)
exchange_name = options.fetch(:exchange)
routing_key = options.fetch(:routing_key)
queue_name = options.fetch(:queue)
amqp_url = options[:url]
retry_limit = options[:retry_limit]
retry_delay = options[:retry_delay]
logger = options[:logger]
on_uncaught_exception = options[:on_uncaught_exception]
worker = Tackle::Worker.new(exchange_name,
routing_key,
queue_name,
:url => amqp_url,
:retry_limit => retry_limit,
:retry_delay => retry_delay,
:logger => logger,
:on_uncaught_exception => on_uncaught_exception)
worker.subscribe(&block)
end
|