def test_api_call_context(pingpong_thrift_client, pingpong_service_key, pingpong_thrift_service, fake_time): from thrift_connector.hooks import before_call, after_call mock_before_hook = Mock() mock_after_hook = Mock() before_call.register(mock_before_hook) after_call.register(mock_after_hook) pool = ClientPool( pingpong_thrift_service, pingpong_thrift_client.host, pingpong_thrift_client.port, name=pingpong_service_key, raise_empty=False, max_conn=3, connction_class=pingpong_thrift_client.pool.connction_class, ) pool.ping() # get one client manually, there should be one client in pool, # since there's only one call client = pool.get_client() assert client.test_connection() pool.put_back_connection(client) mock_before_hook.assert_called_with(pool, client, 'ping', fake_time.time()) mock_after_hook.assert_called_with(pool, client, 'ping', fake_time.time(), 0)
def test_api_call_context( pingpong_thrift_client, pingpong_service_key, pingpong_thrift_service, fake_time): from thrift_connector.hooks import before_call, after_call mock_before_hook = Mock() mock_after_hook = Mock() before_call.register(mock_before_hook) after_call.register(mock_after_hook) pool = ClientPool( pingpong_thrift_service, pingpong_thrift_client.host, pingpong_thrift_client.port, name=pingpong_service_key, raise_empty=False, max_conn=3, connction_class=pingpong_thrift_client.pool.connction_class, ) pool.ping() # get one client manually, there should be one client in pool, # since there's only one call client = pool.get_client() assert client.test_connection() pool.put_back_connection(client) mock_before_hook.assert_called_with(pool, client, 'ping', fake_time.time()) mock_after_hook.assert_called_with(pool, client, 'ping', fake_time.time(), 0)
# -*- coding: utf-8 -*- import thriftpy from thrift_connector import ClientPool, ThriftPyCyClient service = thriftpy.load("pingpong_app/pingpong.thrift") pool = ClientPool( service.PingService, 'localhost', 8880, connction_class=ThriftPyCyClient ) print "Sending Ping..." print "Receive:", pool.ping() print "Winning the match..." print "Receive:", pool.win()
# -*- coding: utf-8 -*- from __future__ import print_function import thriftpy from thrift_connector import ClientPool, ThriftPyCyClient service = thriftpy.load("pingpong_app/pingpong.thrift") pool = ClientPool(service.PingService, 'localhost', 8880, connection_class=ThriftPyCyClient) print("Sending Ping...") print("Receive:", pool.ping()) print("Winning the match...") print("Receive:", pool.win())
# -*- coding: utf-8 -*- import thriftpy from thrift_connector import ClientPool, ThriftPyCyClient service = thriftpy.load("pingpong_app/pingpong.thrift") pool = ClientPool(service.PingService, 'localhost', 8880, connction_class=ThriftPyCyClient) print "Sending Ping..." print "Receive:", pool.ping() print "Winning the match..." print "Receive:", pool.win()
# -*- coding: utf-8 -*- from __future__ import print_function from pingpong_app.pingpong_sdk.pingpong import PingService from thrift_connector import ClientPool, ThriftClient pool = ClientPool( PingService, 'localhost', 8880, connection_class=ThriftClient ) print("Sending Ping...") print("Receive:", pool.ping()) print("Winning the match...") print("Receive:", pool.win())