Sha256: 865c8f9dfeb66181ce4ebbb69af95404771110455f5df4ea01aa194260c39f6f
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true require 'bunny' module Mnemosyne class Client attr_reader :connection def initialize(config) @config = config end def connection @connection ||= begin @config.logger.info "[Mnemosyne] Connect to #{@config.server}..." connection = ::Bunny.new @config.amqp, logger: @config.logger, threaded: false connection.start connection end end def channel @channel ||= connection.create_channel end def exchange @exchange ||= channel.topic @config.exchange, durable: true end def call(trace) message = { hostname: @config.hostname, platform: @config.platform, application: @config.application } # TODO: nest message.merge! trace.serialize exchange.publish JSON.dump(message), persistent: true, routing_key: "mnemosyne.trace.#{@config.platform}", content_type: 'application/json' end class << self def instance @instance ||= new end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mnemosyne-ruby-1.2.0 | lib/mnemosyne/client.rb |
mnemosyne-ruby-1.1.0 | lib/mnemosyne/client.rb |