def run(scenario, channel): stub = services_pb2_grpc.FirstServiceStub(channel) try: return _IMPLEMENTATIONS[scenario](stub) except grpc.RpcError as rpc_error: return Outcome(Outcome.Kind.RPC_ERROR, rpc_error.code(), rpc_error.details())
def _create_client_stub( port, expect_success, root_certificates=None, private_key=None, certificate_chain=None,): channel = grpc.secure_channel('localhost:{}'.format(port), grpc.ssl_channel_credentials( root_certificates=root_certificates, private_key=private_key, certificate_chain=certificate_chain)) if expect_success: # per Nathaniel: there's some robustness issue if we start # using a channel without waiting for it to be actually ready grpc.channel_ready_future(channel).result(timeout=10) return services_pb2_grpc.FirstServiceStub(channel)
def run(scenario, channel): stub = services_pb2_grpc.FirstServiceStub(channel) try: if scenario is Scenario.UNARY_UNARY: return _run_unary_unary(stub) elif scenario is Scenario.UNARY_STREAM: return _run_unary_stream(stub) elif scenario is Scenario.STREAM_UNARY: return _run_stream_unary(stub) elif scenario is Scenario.STREAM_STREAM: return _run_stream_stream(stub) elif scenario is Scenario.CONCURRENT_STREAM_UNARY: return _run_concurrent_stream_unary(stub) elif scenario is Scenario.CONCURRENT_STREAM_STREAM: return _run_concurrent_stream_stream(stub) elif scenario is Scenario.CANCEL_UNARY_UNARY: return _run_cancel_unary_unary(stub) elif scenario is Scenario.INFINITE_REQUEST_STREAM: return _run_infinite_request_stream(stub) except grpc.RpcError as rpc_error: return Outcome(Outcome.Kind.RPC_ERROR, rpc_error.code(), rpc_error.details())
def _create_client_stub(channel, expect_success): if expect_success: # per Nathaniel: there's some robustness issue if we start # using a channel without waiting for it to be actually ready grpc.channel_ready_future(channel).result(timeout=10) return services_pb2_grpc.FirstServiceStub(channel)