Class: Pgbus::EventBus::Subscriber
- Inherits:
-
Object
- Object
- Pgbus::EventBus::Subscriber
- Defined in:
- lib/pgbus/event_bus/subscriber.rb
Instance Attribute Summary collapse
-
#handler_class ⇒ Object
readonly
Returns the value of attribute handler_class.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
-
#queue_name ⇒ Object
readonly
Returns the value of attribute queue_name.
Instance Method Summary collapse
-
#initialize(pattern:, handler_class:, queue_name: nil) ⇒ Subscriber
constructor
A new instance of Subscriber.
- #setup! ⇒ Object
Constructor Details
#initialize(pattern:, handler_class:, queue_name: nil) ⇒ Subscriber
Returns a new instance of Subscriber.
8 9 10 11 12 |
# File 'lib/pgbus/event_bus/subscriber.rb', line 8 def initialize(pattern:, handler_class:, queue_name: nil) @pattern = pattern @handler_class = handler_class @queue_name = queue_name || derive_queue_name end |
Instance Attribute Details
#handler_class ⇒ Object (readonly)
Returns the value of attribute handler_class.
6 7 8 |
# File 'lib/pgbus/event_bus/subscriber.rb', line 6 def handler_class @handler_class end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
6 7 8 |
# File 'lib/pgbus/event_bus/subscriber.rb', line 6 def pattern @pattern end |
#queue_name ⇒ Object (readonly)
Returns the value of attribute queue_name.
6 7 8 |
# File 'lib/pgbus/event_bus/subscriber.rb', line 6 def queue_name @queue_name end |
Instance Method Details
#setup! ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/pgbus/event_bus/subscriber.rb', line 14 def setup! Pgbus.client.ensure_queue(queue_name) # Subscriber queues are created here, not by a worker, so this is their # creation hook for the fair-share index (issue #427). Idempotent and # memoized per process; instant on a fresh table, CONCURRENTLY otherwise. Pgbus.client.ensure_fair_index(queue_name) if FairShare.event_enabled? Pgbus.client.bind_topic(pattern, queue_name) end |