def thrift(respw, server, transport, **kwargs): rpc = RPC( service='client', outbounds={ 'yarpc-test': tr.factory(server, transport), }, ) expected = rand.string(7) request = Request( body=service.Echo.echo(service.Ping(beep=expected)), ttl=10000, ) client = ThriftClient(rpc.channel('yarpc-test')) response = yield client.call(request) if response.body.boop == expected: respw.success("Server said: %s" % response.body.boop) else: respw.fail("expected %s, got %s" % (expected, response.body))
class ThriftCaller(object): def __init__(self, channel): self._client = ThriftClient(channel) def call(self, headers): request = Request( body=service.Echo.echo(service.Ping(beep='boop')), ttl=10000, headers=headers, ) return self._client.call(request)
def __init__(self, channel): self._client = ThriftClient(channel)