Class: Mnemosyne::Client
- Inherits:
-
Object
- Object
- Mnemosyne::Client
- Defined in:
- lib/mnemosyne/client.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Class Method Summary collapse
Instance Method Summary collapse
- #call(trace) ⇒ Object
- #channel ⇒ Object
- #exchange ⇒ Object
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(config) ⇒ Client
Returns a new instance of Client.
8 9 10 |
# File 'lib/mnemosyne/client.rb', line 8 def initialize(config) @config = config end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
6 7 8 |
# File 'lib/mnemosyne/client.rb', line 6 def connection @connection end |
Class Method Details
.instance ⇒ Object
50 51 52 |
# File 'lib/mnemosyne/client.rb', line 50 def instance @instance ||= new end |
Instance Method Details
#call(trace) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/mnemosyne/client.rb', line 33 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
25 26 27 |
# File 'lib/mnemosyne/client.rb', line 25 def channel @channel ||= connection.create_channel end |
#exchange ⇒ Object
29 30 31 |
# File 'lib/mnemosyne/client.rb', line 29 def exchange @exchange ||= channel.topic @config.exchange, durable: true end |