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


Python thrift.load函数代码示例

本文整理汇总了Python中tchannel.thrift.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了load函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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