Class: NATS::RPC::Client
- Inherits:
-
Object
- Object
- NATS::RPC::Client
- Defined in:
- lib/nats/rpc/client.rb
Instance Method Summary collapse
-
#initialize(servers: ["nats://127.0.0.1:4222"]) ⇒ Client
constructor
A new instance of Client.
- #request(subscription, obj, opts) ⇒ Object
Constructor Details
Instance Method Details
#request(subscription, obj, opts) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nats/rpc/client.rb', line 9 def request(subscription, obj, opts) obj_json = if obj.is_a? String obj else obj.to_json end msg = @nats.request 'testing', obj_json, opts data = JSON.parse(msg["data"]) payload = JSON.parse(data["payload"]) [data, payload] end |