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
- #channel ⇒ Object
- #exchange ⇒ Object
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
- #send(key, data) ⇒ Object
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
43 44 45 |
# File 'lib/mnemosyne/client.rb', line 43 def instance @instance ||= new end |
Instance Method Details
#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 |
#send(key, data) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/mnemosyne/client.rb', line 33 def send(key, data) blob = JSON.dump data exchange.publish blob, routing_key: key, persistent: true, content_type: 'application/json' end |