Class: TDL::Client
- Inherits:
-
Object
- Object
- TDL::Client
- Defined in:
- lib/tdl/client.rb
Defined Under Namespace
Classes: ApplyProcessingRules
Instance Method Summary collapse
- #go_live_with(processing_rules) ⇒ Object
-
#initialize(hostname:, port: 61613, username:) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(hostname:, port: 61613, username:) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 |
# File 'lib/tdl/client.rb', line 13 def initialize(hostname:, port: 61613, username:) @hostname = hostname @port = port @username = username @logger = Logging.logger[self] end |
Instance Method Details
#go_live_with(processing_rules) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/tdl/client.rb', line 20 def go_live_with(processing_rules) begin @logger.info 'Starting client.' remote_broker = RemoteBroker.new(@hostname, @port, @username) remote_broker.subscribe(ApplyProcessingRules.new(processing_rules)) #DEBT: We should have no timeout here. We could put a special message in the queue remote_broker.join(3) @logger.info 'Stopping client.' remote_broker.close rescue Exception => e # raise e if ENV['TDL_ENV'] == 'test' @logger.error "There was a problem processing messages. #{e.message}" @logger.error e.backtrace.join("\n") end end |