コード例 #1
0
ファイル: headers.py プロジェクト: yarpc/yarpc-python
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)
コード例 #2
0
ファイル: json.py プロジェクト: yarpc/yarpc-python
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))
コード例 #3
0
ファイル: json.py プロジェクト: yarpc/yarpc-python
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))