当前位置: 首页>>代码示例>>Python>>正文


Python TChannel.request方法代码示例

本文整理汇总了Python中tchannel.tornado.TChannel.request方法的典型用法代码示例。如果您正苦于以下问题:Python TChannel.request方法的具体用法?Python TChannel.request怎么用?Python TChannel.request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tchannel.tornado.TChannel的用法示例。


在下文中一共展示了TChannel.request方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_zipkin_trace

# 需要导入模块: from tchannel.tornado import TChannel [as 别名]
# 或者: from tchannel.tornado.TChannel import request [as 别名]
def test_zipkin_trace(trace_server):
    endpoint = b'endpoint1'
    zipkin_tracer = ZipkinTraceHook(dst=trace_buf)
    tchannel = TChannel(name='test')
    tchannel.hooks.register(zipkin_tracer)

    hostport = 'localhost:%d' % trace_server.port

    response = yield tchannel.request(hostport).send(InMemStream(endpoint),
                                                     InMemStream(hostport),
                                                     InMemStream(),
                                                     traceflag=True)
    header = yield response.get_header()
    body = yield response.get_body()
    assert header == "from handler1"
    assert body == "from handler2"
    traces = []
    for trace in trace_buf.getvalue().split("\n"):
        if trace:
            traces.append(json.loads(trace))

    trace_id = traces[0][0][u'trace_id']
    for trace in traces:
        assert trace_id == trace[0][u'trace_id']
        if trace[0][u'name'] == u'endpoint2':
            parent_span_id = trace[0][u'parent_span_id']
        else:
            span_id = trace[0][u'span_id']

    assert parent_span_id == span_id
开发者ID:Willyham,项目名称:tchannel-python,代码行数:32,代码来源:test_zipkin_trace.py

示例2: test_request

# 需要导入模块: from tchannel.tornado import TChannel [as 别名]
# 或者: from tchannel.tornado.TChannel import request [as 别名]
def test_request():
    channel = TChannel(name="test")
    hyperbahn.advertise(channel, "foo", ["127.0.0.1:23000"])

    # Just want to make sure all the plumbing fits together.

    with pytest.raises(NoAvailablePeerError):
        yield channel.request(service="bar").send(arg1="baz", arg2="bam", arg3="boo", headers={"as": "qux"})
开发者ID:webmaven,项目名称:tchannel-python,代码行数:10,代码来源:test_hyperbahn.py

示例3: test_endpoint_not_found

# 需要导入模块: from tchannel.tornado import TChannel [as 别名]
# 或者: from tchannel.tornado.TChannel import request [as 别名]
def test_endpoint_not_found(tchannel_server):
    endpoint = b"tchanneltest"
    tchannel_server.expect_call(endpoint).and_write(headers=endpoint, body="world")
    tchannel = TChannel(name="test")

    hostport = "localhost:%d" % (tchannel_server.port)

    with pytest.raises(TChannelError):
        yield tchannel.request(hostport).send(InMemStream(), InMemStream(), InMemStream())
开发者ID:pengzhai,项目名称:tchannel,代码行数:11,代码来源:test_client_server.py

示例4: send_stream

# 需要导入模块: from tchannel.tornado import TChannel [as 别名]
# 或者: from tchannel.tornado.TChannel import request [as 别名]
def send_stream(arg1, arg2, arg3, host):
    tchannel = TChannel()
    response = yield tchannel.request(host).send(
        arg1,
        arg2,
        arg3)

    yield print_arg(response, 0)
    yield print_arg(response, 1)
    yield print_arg(response, 2)
开发者ID:jonasrosland,项目名称:tchannel,代码行数:12,代码来源:stream_client.py

示例5: send_stream

# 需要导入模块: from tchannel.tornado import TChannel [as 别名]
# 或者: from tchannel.tornado.TChannel import request [as 别名]
def send_stream(arg1, arg2, arg3, host):
    tchannel = TChannel(
        name='stream-client',
    )

    yield tchannel.request(host).send(
        arg1,
        arg2,
        arg3,
    )
开发者ID:invincible1388,项目名称:tchannel-python,代码行数:12,代码来源:stream_client.py

示例6: test_request

# 需要导入模块: from tchannel.tornado import TChannel [as 别名]
# 或者: from tchannel.tornado.TChannel import request [as 别名]
def test_request():
    channel = TChannel()
    hyperbahn.advertise(channel, 'foo', ['127.0.0.1:23000'])

    # Just want to make sure all the plumbing fits together.
    with pytest.raises(ConnectionClosedError):
        yield channel.request(service='bar').send(
            arg1='baz',
            arg2='bam',
            arg3='boo',
            headers={'as': 'qux'},
        )
开发者ID:oibe,项目名称:tchannel,代码行数:14,代码来源:test_hyperbahn.py

示例7: test_endpoint_not_found

# 需要导入模块: from tchannel.tornado import TChannel [as 别名]
# 或者: from tchannel.tornado.TChannel import request [as 别名]
def test_endpoint_not_found(mock_server):
    endpoint = b'tchanneltest'
    mock_server.expect_call(endpoint).and_write(
        headers=endpoint,
        body='world'
    )
    tchannel = TChannel(name='test')

    with pytest.raises(TChannelError):
        yield tchannel.request(
            mock_server.hostport
        ).send(InMemStream(), InMemStream(), InMemStream())
开发者ID:Willyham,项目名称:tchannel-python,代码行数:14,代码来源:test_client_server.py

示例8: main

# 需要导入模块: from tchannel.tornado import TChannel [as 别名]
# 或者: from tchannel.tornado.TChannel import request [as 别名]
def main():

    args = get_args()

    tchannel = TChannel(name="raw-client")

    request = tchannel.request(hostport="%s:%s" % (args.host, args.port))

    response = yield request.send("hi", None, None)

    body = yield response.get_body()

    print body
开发者ID:invincible1388,项目名称:tchannel-python,代码行数:15,代码来源:raw_client.py

示例9: test_endpoint_not_found

# 需要导入模块: from tchannel.tornado import TChannel [as 别名]
# 或者: from tchannel.tornado.TChannel import request [as 别名]
def test_endpoint_not_found(tchannel_server):
    endpoint = b'tchanneltest'
    tchannel_server.expect_call(endpoint).and_write(
        headers=endpoint,
        body='world'
    )
    tchannel = TChannel()

    hostport = 'localhost:%d' % (tchannel_server.port)

    with pytest.raises(TChannelError):
        yield tchannel.request(hostport).send(InMemStream(),
                                              InMemStream(),
                                              InMemStream())
开发者ID:oibe,项目名称:tchannel,代码行数:16,代码来源:test_client_server.py

示例10: test_tchannel_call_request_fragment

# 需要导入模块: from tchannel.tornado import TChannel [as 别名]
# 或者: from tchannel.tornado.TChannel import request [as 别名]
def test_tchannel_call_request_fragment(tchannel_server, arg2, arg3):
    endpoint = b"tchannelpeertest"

    tchannel_server.expect_call(endpoint).and_write(headers=endpoint, body=arg3)

    tchannel = TChannel(name="test")

    hostport = "localhost:%d" % (tchannel_server.port)

    response = yield tchannel.request(hostport).send(InMemStream(endpoint), InMemStream(arg2), InMemStream(arg3))
    header = yield response.get_header()
    body = yield response.get_body()
    assert header == endpoint
    assert body == arg3
    assert response.headers["as"] == "raw"
开发者ID:pengzhai,项目名称:tchannel,代码行数:17,代码来源:test_client_server.py

示例11: test_tchannel_call_request_fragment

# 需要导入模块: from tchannel.tornado import TChannel [as 别名]
# 或者: from tchannel.tornado.TChannel import request [as 别名]
def test_tchannel_call_request_fragment(mock_server,
                                        arg2, arg3):
    endpoint = b'tchannelpeertest'

    mock_server.expect_call(endpoint).and_write(
        headers=endpoint, body=arg3
    )

    tchannel = TChannel(name='test')
    response = yield tchannel.request(mock_server.hostport).send(
        InMemStream(endpoint), InMemStream(arg2), InMemStream(arg3)
    )
    header = yield response.get_header()
    body = yield response.get_body()
    assert header == endpoint
    assert body == arg3
    assert response.headers['as'] == 'raw'
开发者ID:Willyham,项目名称:tchannel-python,代码行数:19,代码来源:test_client_server.py

示例12: test_false_result

# 需要导入模块: from tchannel.tornado import TChannel [as 别名]
# 或者: from tchannel.tornado.TChannel import request [as 别名]
def test_false_result(thrift_service):
    # Verify that we aren't treating False as None.

    app = TChannel(name='app')

    @app.register(thrift_service)
    def healthy(request, response):
        return False

    app.listen()

    client = TChannel(name='client')
    response = yield client.request(
        hostport=app.hostport, arg_scheme='thrift'
    ).send('Service::healthy', '\x00\x00', '\x00')

    body = yield response.get_body()
    assert body == '\x02\x00\x00\x00\x00'
开发者ID:encrylife,项目名称:tchannel-python,代码行数:20,代码来源:test_tornado_client.py

示例13: test_json_server

# 需要导入模块: from tchannel.tornado import TChannel [as 别名]
# 或者: from tchannel.tornado.TChannel import request [as 别名]
def test_json_server(json_server, sample_json):
    endpoint = "json_echo"
    tchannel = TChannel(name='test')
    hostport = 'localhost:%d' % json_server.port
    client = tchannel.request(hostport)
    header = sample_json
    body = sample_json
    resp = yield ArgSchemeBroker(JsonArgScheme()).send(
        client,
        endpoint,
        header,
        body,
    )

    # compare header's json
    rheader = yield resp.get_header()
    assert rheader == header

    # compare body's json
    rbody = yield resp.get_body()
    assert rbody == body
开发者ID:jonasrosland,项目名称:tchannel,代码行数:23,代码来源:test_json_server.py

示例14: test_json_server

# 需要导入模块: from tchannel.tornado import TChannel [as 别名]
# 或者: from tchannel.tornado.TChannel import request [as 别名]
def test_json_server(json_server, sample_json):
    endpoint = "json_echo"
    tchannel = TChannel(name='test')
    client = tchannel.request(json_server.hostport)
    header = sample_json
    body = sample_json
    resp = yield ArgSchemeBroker(JsonArgScheme()).send(
        client,
        endpoint,
        header,
        body,
    )

    # check protocol header
    assert resp.headers['as'] == 'json'
    # compare header's json
    rheader = yield resp.get_header()
    assert rheader == header

    # compare body's json
    rbody = yield resp.get_body()
    assert rbody == body
开发者ID:invincible1388,项目名称:tchannel-python,代码行数:24,代码来源:test_json_server.py

示例15: test_patching_as_context_manager

# 需要导入模块: from tchannel.tornado import TChannel [as 别名]
# 或者: from tchannel.tornado.TChannel import request [as 别名]
def test_patching_as_context_manager():
    chan = TChannel('client')
    with Patcher('localhost:4040'):
        ops = chan.request(service='foo')
        assert isinstance(ops, PatchedClientOperation)
        assert ops.vcr_hostport == 'localhost:4040'
开发者ID:encrylife,项目名称:tchannel-python,代码行数:8,代码来源:test_patcher.py


注:本文中的tchannel.tornado.TChannel.request方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。