class JSONCaller(object): def __init__(self, channel): self._client = JSONClient(channel) def call(self, headers): request = Request( procedure='echo', ttl=10000, headers=headers, ) return self._client.call(request)
def json(respw, server, transport, **kwargs): rpc = RPC(service="client", outbounds={"yarpc-test": tr.factory(server, transport)}) expected = {"token": rand.string(7)} request = Request(procedure="echo", body=expected, ttl=10000) client = JSONClient(rpc.channel("yarpc-test")) response = yield client.call(request) if response.body == expected: respw.success("Server said: %s" % response.body["token"]) else: respw.fail("expected %s, got %s" % (expected, response.body))
def json(respw, server, transport, **kwargs): rpc = RPC( service='client', outbounds={ 'yarpc-test': tr.factory(server, transport), }, ) expected = { 'token': rand.string(7), } request = Request(procedure='echo', body=expected, ttl=10000) client = JSONClient(rpc.channel('yarpc-test')) future = client.call(request) response = future.result() if response.body == expected: respw.success("Server said: %s" % response.body['token']) else: respw.fail("expected %s, got %s" % (expected, response.body))