Class: Chore::Publisher
- Inherits:
-
Object
- Object
- Chore::Publisher
- Defined in:
- lib/chore/publisher.rb
Overview
Base class for a Chore Publisher. Provides the interface that a Chore::Publisher implementation should adhere to.
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :encoder => Encoder::JsonEncoder }
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
-
.publish(queue_name, job) ⇒ Object
Publishes the provided
job
to the queue identified by thequeue_name
. -
.reset_connection! ⇒ Object
Sets a flag that instructs the publisher to reset the connection the next time it's used.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Publisher
constructor
A new instance of Publisher.
-
#publish(queue_name, job) ⇒ Object
Publishes a message to queue.
Constructor Details
#initialize(opts = {}) ⇒ Publisher
Returns a new instance of Publisher.
9 10 11 |
# File 'lib/chore/publisher.rb', line 9 def initialize(opts={}) self. = DEFAULT_OPTIONS.merge(opts) end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/chore/publisher.rb', line 6 def @options end |
Class Method Details
.publish(queue_name, job) ⇒ Object
Publishes the provided job
to the queue identified by the
queue_name
. Not designed to be used directly, this method
ferries to the publish method on an instance of your configured Publisher.
18 19 20 |
# File 'lib/chore/publisher.rb', line 18 def self.publish(queue_name,job) self.new.publish(queue_name,job) end |
.reset_connection! ⇒ Object
Sets a flag that instructs the publisher to reset the connection the next time it's used. Should be overriden in publishers (but is not required)
32 33 |
# File 'lib/chore/publisher.rb', line 32 def self.reset_connection! end |
Instance Method Details
#publish(queue_name, job) ⇒ Object
Publishes a message to queue
26 27 28 |
# File 'lib/chore/publisher.rb', line 26 def publish(queue_name,job) raise NotImplementedError end |