Class: Chasqui::Broker
- Inherits:
-
Object
- Object
- Chasqui::Broker
- Extended by:
- Forwardable
- Defined in:
- lib/chasqui/broker.rb
Direct Known Subclasses
Constant Summary collapse
- ShutdownSignals =
%w(INT QUIT ABRT TERM).freeze
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#redis ⇒ Object
readonly
Returns the value of attribute redis.
-
#redis_namespace ⇒ Object
readonly
Returns the value of attribute redis_namespace.
Class Method Summary collapse
Instance Method Summary collapse
- #forward_event ⇒ Object
-
#initialize ⇒ Broker
constructor
A new instance of Broker.
- #start ⇒ Object
Constructor Details
#initialize ⇒ Broker
Returns a new instance of Broker.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/chasqui/broker.rb', line 11 def initialize @shutdown_requested = nil @config = Chasqui.config.dup @redis_namespace = @config.redis.namespace # The broker uses it's own private redis connection for two reasons: # 1. subscribers may use a different (or no) redis namespace than chasqui # 2. sharing the connection with unsuspecting clients could result in # the broker blocking forever @redis = Redis.new @config.redis.client. end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/chasqui/broker.rb', line 4 def config @config end |
#redis ⇒ Object (readonly)
Returns the value of attribute redis.
4 5 6 |
# File 'lib/chasqui/broker.rb', line 4 def redis @redis end |
#redis_namespace ⇒ Object (readonly)
Returns the value of attribute redis_namespace.
4 5 6 |
# File 'lib/chasqui/broker.rb', line 4 def redis_namespace @redis_namespace end |
Class Method Details
.start ⇒ Object
37 38 39 |
# File 'lib/chasqui/broker.rb', line 37 def start Chasqui::MultiBroker.new.start end |
Instance Method Details
#forward_event ⇒ Object
32 33 34 |
# File 'lib/chasqui/broker.rb', line 32 def forward_event raise NotImplementedError.new "please define #forward_event in a subclass of #{self.class.name}" end |
#start ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/chasqui/broker.rb', line 23 def start install_signal_handlers logger.info "broker started with pid #{Process.pid}" logger.info "configured to fetch events from #{inbox} on #{redis.inspect}" until_shutdown_requested { forward_event } end |