本文整理汇总了Python中tchannel.thrift.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_inherited_method_names
def test_inherited_method_names(tmpdir):
thrift_file = tmpdir.join('service.thrift')
thrift_file.write('''
service Base { string hello() }
service Foo extends Base {}
service Bar extends Base {}
''')
service = thrift.load(str(thrift_file), 'myservice')
server = TChannel('server')
@server.thrift.register(service.Foo, method='hello')
def foo_hello(request):
return 'foo'
@server.thrift.register(service.Bar, method='hello')
def bar_hello(request):
return 'bar'
server.listen()
client = TChannel('client')
res = yield client.thrift(service.Foo.hello(), hostport=server.hostport)
assert res.body == 'foo'
res = yield client.thrift(service.Bar.hello(), hostport=server.hostport)
assert res.body == 'bar'
开发者ID:dnathe4th,项目名称:tchannel-python,代码行数:29,代码来源:test_multiple_services.py
示例2: test_service_inheritance
def test_service_inheritance(tmpdir):
path = tmpdir.join('myservice.thrift')
path.write('''
service Base { bool healthy() }
service MyService extends Base {
i32 getValue()
}
''')
service = thrift.load(str(path), service='myservice')
server = TChannel('server')
server.listen()
@server.thrift.register(service.MyService)
def getValue(request):
return 42
@server.thrift.register(service.MyService)
def healthy(request):
return True
client = TChannel('client', known_peers=[server.hostport])
response = yield client.thrift(service.MyService.getValue())
assert response.body == 42
response = yield client.thrift(service.MyService.healthy())
assert response.body is True
开发者ID:dnathe4th,项目名称:tchannel-python,代码行数:29,代码来源:test_rw.py
示例3: test_thriftrw_client_without_service_or_hostport_specified
def test_thriftrw_client_without_service_or_hostport_specified():
client = thrift.load(
'tests/data/idls/ThriftTest.thrift',
)
with pytest.raises(ValueError):
client.ThriftTest.testVoid()
开发者ID:dnathe4th,项目名称:tchannel-python,代码行数:7,代码来源:test_rw.py
示例4: test_service_inheritance_with_import
def test_service_inheritance_with_import(tmpdir):
tmpdir.join('shared/base.thrift').write(
'service Base { bool healthy() }', ensure=True
)
inherited = tmpdir.join('myservice.thrift')
inherited.write('''
include "./shared/base.thrift"
service MyService extends base.Base {
i32 getValue()
}
''')
service = thrift.load(str(inherited), service='myservice')
server = TChannel('server')
@server.thrift.register(service.MyService)
def getValue(request):
return 42
@server.thrift.register(service.MyService)
def healthy(request):
return True
server.listen()
client = TChannel('client', known_peers=[server.hostport])
response = yield client.thrift(service.MyService.getValue())
assert response.body == 42
response = yield client.thrift(service.MyService.healthy())
assert response.body is True
开发者ID:dnathe4th,项目名称:tchannel-python,代码行数:35,代码来源:test_rw.py
示例5: test_thriftrw_client_with_service_or_hostport_specified
def test_thriftrw_client_with_service_or_hostport_specified(hostport, service):
client = thrift.load(
'tests/data/idls/ThriftTest.thrift',
hostport=hostport,
service=service,
)
assert client.ThriftTest.testVoid()
开发者ID:dnathe4th,项目名称:tchannel-python,代码行数:8,代码来源:test_rw.py
示例6: thrift_module
def thrift_module(tmpdir, request):
thrift_file = tmpdir.join('service.thrift')
thrift_file.write('''
service Service {
bool healthy()
}
''')
return thrift.load(str(thrift_file), request.node.name)
开发者ID:uber,项目名称:tchannel-python,代码行数:8,代码来源:test_tchannel.py
示例7: client_ttypes
def client_ttypes(use_thriftrw_client):
"""Provides access to generated types for the server."""
if use_thriftrw_client:
return thrift.load(
path='tests/data/idls/ThriftTest.thrift',
)
else:
return _ttypes
开发者ID:encrylife,项目名称:tchannel-python,代码行数:9,代码来源:test_thrift.py
示例8: ThriftTest
def ThriftTest(use_thriftrw_server):
"""Used by servers to register endpoints for ThriftTest."""
if use_thriftrw_server:
return thrift.load(
'tests/data/idls/ThriftTest.thrift',
).ThriftTest
else:
return _ThriftTest
开发者ID:encrylife,项目名称:tchannel-python,代码行数:9,代码来源:test_thrift.py
示例9: SecondService
def SecondService(use_thriftrw_server):
"""Used by servers to register endpoints for SecondService."""
if use_thriftrw_server:
return thrift.load(
'tests/data/idls/ThriftTest.thrift',
).SecondService
else:
return _SecondService
开发者ID:encrylife,项目名称:tchannel-python,代码行数:9,代码来源:test_thrift.py
示例10: request_thrift
def request_thrift(tchannel, hostport):
ThriftTest = thrift.load(
path='tests/data/idls/ThriftTest.thrift',
service='server',
).SecondService
return tchannel.thrift(
ThriftTest.blahBlah(),
hostport=hostport,
)
开发者ID:dnathe4th,项目名称:tchannel-python,代码行数:10,代码来源:test_client.py
示例11: register_thrift
def register_thrift(tchannel):
ThriftTest = thrift.load(
path='tests/data/idls/ThriftTest.thrift',
service='server',
).SecondService
@tchannel.thrift.register(ThriftTest)
def hello(request):
return
开发者ID:dnathe4th,项目名称:tchannel-python,代码行数:10,代码来源:test_client.py
示例12: test_default_checksum_type
def test_default_checksum_type():
server = TChannel("server")
server.listen()
with mock.patch("tchannel.messages.common.compute_checksum", autospec=True) as mock_compute_checksum:
client = TChannel("client")
service = thrift.load(
path="tchannel/health/meta.thrift", service="health_test_server", hostport=server.hostport
)
with pytest.raises(FatalProtocolError):
yield client.thrift(service.Meta.health())
mock_compute_checksum.assert_called_with(ChecksumType.crc32c, mock.ANY, mock.ANY)
开发者ID:uber,项目名称:tchannel-python,代码行数:12,代码来源:test_checksum.py
示例13: thrift_service
def thrift_service(tmpdir):
thrift_file = tmpdir.join('service.thrift')
thrift_file.write('''
service X {
string thrift1(1: string hostport), // calls thrift2()
string thrift2(),
string thrift3(1: string hostport) // calls http
string thrift4(1: string hostport) // calls raw
}
''')
return thrift.load(str(thrift_file), 'test-service')
开发者ID:uber,项目名称:tchannel-python,代码行数:12,代码来源:test_tracing.py
示例14: keyvalue
def keyvalue(tmpdir):
path = tmpdir.join('keyvalue.thrift')
path.write('''
exception ItemDoesNotExist {
1: optional string key
}
service KeyValue {
string getItem(1: string key)
throws (1: ItemDoesNotExist doesNotExist)
}
''')
return thrift.load(str(path), service='keyvalue')
开发者ID:dnathe4th,项目名称:tchannel-python,代码行数:14,代码来源:test_forwarding.py
示例15: second_service
def second_service(server, use_thriftrw_client):
"""Used by clients to build requests to SecondService."""
if use_thriftrw_client:
return thrift.load(
path='tests/data/idls/ThriftTest.thrift',
service='server',
hostport=server.hostport,
).SecondService
else:
return thrift_request_builder(
service='server',
thrift_module=_SecondService,
hostport=server.hostport,
)
开发者ID:encrylife,项目名称:tchannel-python,代码行数:15,代码来源:test_thrift.py
示例16: test_default_health
def test_default_health():
server = TChannel("health_test_server")
server.listen()
client = TChannel("health_test_client")
service = thrift.load(
path='tchannel/health/meta.thrift',
service='health_test_server',
hostport=server.hostport,
)
resp = yield client.thrift(service.Meta.health())
assert resp.body.ok is True
assert resp.body.message is None
开发者ID:encrylife,项目名称:tchannel-python,代码行数:15,代码来源:test_health.py
示例17: test_routing_delegate_is_propagated_thrift
def test_routing_delegate_is_propagated_thrift(tmpdir):
tmpdir.join('service.thrift').write('service Service { bool healthy() }')
thrift_module = thrift.load(str(tmpdir.join('service.thrift')),
service='service')
server = TChannel('server')
server.listen()
@server.thrift.register(thrift_module.Service)
def healthy(request):
assert request.transport.routing_delegate == 'delegate'
return True
client = TChannel('client', known_peers=[server.hostport])
res = yield client.thrift(
thrift_module.Service.healthy(), routing_delegate='delegate'
)
assert res.body is True
开发者ID:dnathe4th,项目名称:tchannel-python,代码行数:18,代码来源:test_dispatch.py
示例18: test_user_health
def test_user_health():
server = TChannel("health_test_server")
@server.thrift.register(Meta, method="health")
def user_health(request):
return HealthStatus(ok=False, message="from me")
server.listen()
client = TChannel("health_test_client")
service = thrift.load(
path='tchannel/health/meta.thrift',
service='health_test_server',
hostport=server.hostport,
)
resp = yield client.thrift(service.Meta.health())
assert resp.body.ok is False
assert resp.body.message == "from me"
开发者ID:encrylife,项目名称:tchannel-python,代码行数:19,代码来源:test_health.py
示例19: real_call_downstream_tchannel
def real_call_downstream_tchannel(self, span, trace_request, trace_response, response_writer):
def handle_response(f):
response = f.result()
trace_response.downstream = response.body
response_writer.write(serializer.obj_to_json(trace_response))
response_writer.finish()
downstream = trace_request.downstream
# XXX cache these
service = thrift.load(idl_path, service=downstream.serviceName)
jtr = JoinTraceRequest(trace_request.serverRole, downstream.downstream)
jtr = join_trace_request_to_thriftrw(service, jtr)
# with context.RequestContext(span):
with context.request_context(span):
f = tchannel.thrift(service.TracedService.joinTrace(jtr),
hostport="%s:%s" % (downstream.host, downstream.port))
tornado.ioloop.IOLoop.current().add_future(f, handle_response)
开发者ID:thepaulm,项目名称:jaeger-client-python,代码行数:20,代码来源:server.py
示例20: test_req_body_is_wire_compat_with_tchannel
def test_req_body_is_wire_compat_with_tchannel(service):
args = {
'string_thing': 'hi',
'byte_thing': 1,
'i32_thing': -1,
'i64_thing': -34359738368,
}
# serialize object using yarpc's thrift.load
xtruct = service.Xtruct(**args)
req_body = service.ThriftTest.testStruct(xtruct)
wire = req_body.__thrift_module__.dumps(req_body) # non-enveloped
# now serialize using tchannel's thrift.load
tch_service = tch_thrift.load(idl, service='...', hostport='...')
tch_xtruct = tch_service.Xtruct(**args)
tch_req_body = tch_service.ThriftTest.testStruct(tch_xtruct)
tch_serializer = tch_req_body.get_serializer()
tch_wire = tch_serializer.serialize_body(tch_req_body.call_args)
assert wire == tch_wire
开发者ID:yarpc,项目名称:yarpc-python,代码行数:21,代码来源:test_thrift.py
注:本文中的tchannel.thrift.load函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论