Class: DataCollector::Output::Rpc

Inherits:
Generic
  • Object
show all
Defined in:
lib/data_collector/output/rpc.rb

Instance Method Summary collapse

Methods inherited from Generic

#running?, #stopped?

Constructor Details

#initialize(uri, options = {}) ⇒ Rpc

Returns a new instance of Rpc.



6
7
8
# File 'lib/data_collector/output/rpc.rb', line 6

def initialize(uri, options = {})
  super
end

Instance Method Details

#send(message) ⇒ Object



10
11
12
13
# File 'lib/data_collector/output/rpc.rb', line 10

def send(message)
  raise DataCollector::Error, "No client found" if @producer.nil? || stopped?
  JSON.parse(@producer.publish(message, @bunny_queue))
end

#stopObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/data_collector/output/rpc.rb', line 15

def stop
  if @producer && @running
    @running = false
    @producer.shutdown
  end
rescue Bunny::ConnectionAlreadyClosed => e
  DataCollector::Core.log(e.message)
rescue StandardError => e
  DataCollector::Core.error(e.message)
end