Class: Mnemosyne::Client
- Inherits:
-
Object
- Object
- Mnemosyne::Client
- Includes:
- Logging
- Defined in:
- lib/mnemosyne/client.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call(trace) ⇒ Object
- #channel ⇒ Object
- #connection ⇒ Object
- #exchange ⇒ Object
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
Methods included from Logging
Constructor Details
#initialize(config) ⇒ Client
Returns a new instance of Client.
9 10 11 |
# File 'lib/mnemosyne/client.rb', line 9 def initialize(config) @config = config end |
Class Method Details
.instance ⇒ Object
51 52 53 |
# File 'lib/mnemosyne/client.rb', line 51 def instance @instance ||= new end |
Instance Method Details
#call(trace) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/mnemosyne/client.rb', line 34 def call(trace) = { hostname: @config.hostname, platform: @config.platform, application: @config.application } # TODO: nest .merge! trace.serialize exchange.publish JSON.dump(), persistent: true, routing_key: "mnemosyne.trace.#{@config.platform}", content_type: 'application/json' end |
#channel ⇒ Object
26 27 28 |
# File 'lib/mnemosyne/client.rb', line 26 def channel @channel ||= connection.create_channel end |
#connection ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mnemosyne/client.rb', line 13 def connection @connection ||= begin logger.info "[Mnemosyne] Connect to #{@config.server}..." connection = ::Bunny.new @config.amqp, logger:, heartbeat: :server connection.start connection end end |
#exchange ⇒ Object
30 31 32 |
# File 'lib/mnemosyne/client.rb', line 30 def exchange @exchange ||= channel.topic @config.exchange, durable: true end |