lib/message_driver/broker.rb in message-driver-0.2.1 vs lib/message_driver/broker.rb in message-driver-0.2.2
- old
+ new
@@ -5,12 +5,10 @@
class Broker
extend Forwardable
attr_reader :adapter, :configuration, :destinations, :consumers, :logger
- def_delegators :@adapter, :stop
-
class << self
def configure(options)
@instance = new(options)
end
@@ -27,14 +25,32 @@
end
end
def initialize(options)
@adapter = resolve_adapter(options[:adapter], options)
+ @stopped = false
@configuration = options
@destinations = {}
@consumers = {}
@logger = options[:logger] || Logger.new(STDOUT).tap{|l| l.level = Logger::INFO}
logger.debug "MessageDriver configured successfully!"
+ end
+
+ def stop
+ @adapter.stop
+ @stopped = true
+ end
+
+ def stopped?
+ @stopped
+ end
+
+ def restart
+ unless stopped?
+ @adapter.stop
+ end
+ @adapter = resolve_adapter(@configuration[:adapter], @configuration)
+ @stopped = false
end
def dynamic_destination(dest_name, dest_options={}, message_props={})
Client.dynamic_destination(dest_name, dest_options, message_props)
end