router/spec/functional/router_spec.rb
# Encodes _data_ as json, decodes reply as json
Encodes _data_ as json, decodes reply as json
Encodes _data_ as json decodes reply as json
def json_request(uri, subj, data=nil, timeout=1)
    reply = nil
    data_enc = data ? Yajl::Encoder.encode(data) : nil
    NATS.start(:uri => uri) do
      NATS.request(subj, data_enc) do |msg|
        reply = JSON.parse(msg, :symbolize_keys => true)
        NATS.stop
      end
      EM.add_timer(timeout) { NATS.stop }
    end
    reply
  end
def json_request ( uri , subj , data = nil , timeout = 1 ) reply = nil data_enc = data ? Yajl :: Encoder . encode ( data ) : nil NATS . start ( :uri => uri ) do NATS . request ( subj , data_enc ) do | msg | reply = JSON . parse ( msg , :symbolize_keys => true ) NATS . stop end EM . add_timer ( timeout ) { NATS . stop } end reply end
Encodes _data_ as json, decodes reply as json
Encodes _data_ as json decodes reply as json
uri
subj
data
timeout