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