def run(): app = TChannel(name='thrift-client') client = client_for('hello', HelloService)(app, 'localhost:8888') response = yield client.hello("world") print response
def test_client_for(ClientTChannel, server, ThriftTest): @server.thrift.register(ThriftTest) def testString(request): return request.body.thing.encode('rot13') tchannel = ClientTChannel(name='client') client = client_for('server', _ThriftTest)( tchannel=tchannel, hostport=server.hostport, ) resp = yield client.testString(thing='foo') assert resp == 'sbb'
def thrift_client(thrift_service, mock_server, use_old_api): if use_old_api: from tchannel.tornado import TChannel return client_for('myservice', thrift_service)( tchannel=TChannel('thrift-client'), hostport=mock_server.hostport, ) else: from tchannel import TChannel from tchannel.thrift import thrift_request_builder myservice = thrift_request_builder('myservice', thrift_service, hostport=mock_server.hostport) return mk_fake_client(TChannel('thrift-client'), myservice)
def thrift_client(thrift_service, mock_server, use_old_api): if use_old_api: from tchannel.tornado import TChannel return client_for('myservice', thrift_service)( tchannel=TChannel('thrift-client'), hostport=mock_server.hostport, ) else: from tchannel import TChannel from tchannel.thrift import thrift_request_builder myservice = thrift_request_builder( 'myservice', thrift_service, hostport=mock_server.hostport ) return mk_fake_client( TChannel('thrift-client'), myservice )
def client(vcr_service): return client_for('vcr', VCRProxy)( TChannel('proxy-client'), hostport=vcr_service.hostport )
def thrift_client(thrift_service, mock_server): return client_for('myservice', thrift_service)( tchannel=TChannel('thrift-client'), hostport=mock_server.hostport, )
def run(): tchannel = TChannel(name='thrift-client') client = client_for('hello', HelloService)(tchannel, 'localhost:4040') response = yield client.hello("world") print response
def thrift_client(thrift_service, mock_server): return client_for("myservice", thrift_service)(tchannel=TChannel("thrift-client"), hostport=mock_server.hostport)
from __future__ import absolute_import import contextlib2 import inspect import wrapt import sys from tchannel.tornado import TChannel from tchannel.thrift import client_for from .cassette import Cassette from .patch import Patcher, force_reset from .server import VCRProxyService, VCRProxy VCRProxyClient = client_for('vcr', VCRProxy) class _CassetteContext(object): """Lets use_cassette be used as a context manager and a decorator.""" def __init__(self, path, record_mode, inject): self.path = path self.record_mode = record_mode self.inject = inject self._exit_stack = contextlib2.ExitStack() def __enter__(self): cassette = self._exit_stack.enter_context( Cassette(path=self.path, record_mode=self.record_mode)
def client(vcr_service): return client_for("vcr", VCRProxy)(TChannel("proxy-client"), hostport=vcr_service.hostport)
def client(vcr_service): return client_for('vcr', VCRProxy)(TChannel('proxy-client'), hostport=vcr_service.hostport)