def _get_last_trade_price_multiple(stock_reply_consumer, control, active): """A stream-request, stream-response test method.""" def stock_reply_for_stock_request(stock_request): control.control() if active(): return stock_pb2.StockReply( symbol=stock_request.symbol, price=_price(stock_request.symbol)) else: raise abandonment.Abandoned() return stream_util.TransformingConsumer( stock_reply_for_stock_request, stock_reply_consumer)
def adaptation(response_consumer, operation_context): rpc_context = _control.RpcContext(operation_context) return stream_util.TransformingConsumer( lambda request: method(request, rpc_context), response_consumer)
def _synchronous_echo(output_consumer): return stream_util.TransformingConsumer(lambda x: x, output_consumer)