buildgrid.server.client.interceptors module
- class buildgrid.server.client.interceptors.InterceptorFunc(*args, **kwargs)
Bases:
Protocol
- amend_call_details(client_call_details, grpc_call_details_class: Any) Any
- class buildgrid.server.client.interceptors.SyncUnaryUnaryInterceptor(func: InterceptorFunc)
Bases:
UnaryUnaryClientInterceptor
- intercept_unary_unary(continuation, client_call_details, request)
Intercepts a unary-unary invocation asynchronously.
- Parameters:
continuation – A function that proceeds with the invocation by executing the next interceptor in chain or invoking the actual RPC on the underlying Channel. It is the interceptor’s responsibility to call it if it decides to move the RPC forward. The interceptor can use response_future = continuation(client_call_details, request) to continue with the RPC. continuation returns an object that is both a Call for the RPC and a Future. In the event of RPC completion, the return Call-Future’s result value will be the response message of the RPC. Should the event terminate with non-OK status, the returned Call-Future’s exception value will be an RpcError.
client_call_details – A ClientCallDetails object describing the outgoing RPC.
request – The request value for the RPC.
- Returns:
An object that is both a Call for the RPC and a Future. In the event of RPC completion, the return Call-Future’s result value will be the response message of the RPC. Should the event terminate with non-OK status, the returned Call-Future’s exception value will be an RpcError.
- class buildgrid.server.client.interceptors.SyncUnaryStreamInterceptor(func: InterceptorFunc)
Bases:
UnaryStreamClientInterceptor
- intercept_unary_stream(continuation, client_call_details, request)
Intercepts a unary-stream invocation.
- Parameters:
continuation – A function that proceeds with the invocation by executing the next interceptor in chain or invoking the actual RPC on the underlying Channel. It is the interceptor’s responsibility to call it if it decides to move the RPC forward. The interceptor can use response_iterator = continuation(client_call_details, request) to continue with the RPC. continuation returns an object that is both a Call for the RPC and an iterator for response values. Drawing response values from the returned Call-iterator may raise RpcError indicating termination of the RPC with non-OK status.
client_call_details – A ClientCallDetails object describing the outgoing RPC.
request – The request value for the RPC.
- Returns:
An object that is both a Call for the RPC and an iterator of response values. Drawing response values from the returned Call-iterator may raise RpcError indicating termination of the RPC with non-OK status. This object should also fulfill the Future interface, though it may not.
- class buildgrid.server.client.interceptors.SyncStreamUnaryInterceptor(func: InterceptorFunc)
Bases:
StreamUnaryClientInterceptor
- intercept_stream_unary(continuation, client_call_details, request_iterator)
Intercepts a stream-unary invocation asynchronously.
- Parameters:
continuation – A function that proceeds with the invocation by executing the next interceptor in chain or invoking the actual RPC on the underlying Channel. It is the interceptor’s responsibility to call it if it decides to move the RPC forward. The interceptor can use response_future = continuation(client_call_details, request_iterator) to continue with the RPC. continuation returns an object that is both a Call for the RPC and a Future. In the event of RPC completion, the return Call-Future’s result value will be the response message of the RPC. Should the event terminate with non-OK status, the returned Call-Future’s exception value will be an RpcError.
client_call_details – A ClientCallDetails object describing the outgoing RPC.
request_iterator – An iterator that yields request values for the RPC.
- Returns:
An object that is both a Call for the RPC and a Future. In the event of RPC completion, the return Call-Future’s result value will be the response message of the RPC. Should the event terminate with non-OK status, the returned Call-Future’s exception value will be an RpcError.
- class buildgrid.server.client.interceptors.SyncStreamStreamInterceptor(func: InterceptorFunc)
Bases:
StreamStreamClientInterceptor
- intercept_stream_stream(continuation, client_call_details, request_iterator)
Intercepts a stream-stream invocation.
- Parameters:
continuation – A function that proceeds with the invocation by executing the next interceptor in chain or invoking the actual RPC on the underlying Channel. It is the interceptor’s responsibility to call it if it decides to move the RPC forward. The interceptor can use response_iterator = continuation(client_call_details, request_iterator) to continue with the RPC. continuation returns an object that is both a Call for the RPC and an iterator for response values. Drawing response values from the returned Call-iterator may raise RpcError indicating termination of the RPC with non-OK status.
client_call_details – A ClientCallDetails object describing the outgoing RPC.
request_iterator – An iterator that yields request values for the RPC.
- Returns:
An object that is both a Call for the RPC and an iterator of response values. Drawing response values from the returned Call-iterator may raise RpcError indicating termination of the RPC with non-OK status. This object should also fulfill the Future interface, though it may not.
- class buildgrid.server.client.interceptors.AsyncUnaryUnaryInterceptor(func: InterceptorFunc)
Bases:
UnaryUnaryClientInterceptor
- async intercept_unary_unary(continuation, client_call_details, request)
Intercepts a unary-unary invocation asynchronously.
- Parameters:
continuation – A coroutine that proceeds with the invocation by executing the next interceptor in the chain or invoking the actual RPC on the underlying Channel. It is the interceptor’s responsibility to call it if it decides to move the RPC forward. The interceptor can use call = await continuation(client_call_details, request) to continue with the RPC. continuation returns the call to the RPC.
client_call_details – A ClientCallDetails object describing the outgoing RPC.
request – The request value for the RPC.
- Returns:
An object with the RPC response.
- Raises:
AioRpcError – Indicating that the RPC terminated with non-OK status.
asyncio.CancelledError – Indicating that the RPC was canceled.
- class buildgrid.server.client.interceptors.AsyncUnaryStreamInterceptor(func: InterceptorFunc)
Bases:
UnaryStreamClientInterceptor
- async intercept_unary_stream(continuation, client_call_details, request)
Intercepts a unary-stream invocation asynchronously.
The function could return the call object or an asynchronous iterator, in case of being an asyncrhonous iterator this will become the source of the reads done by the caller.
- Parameters:
continuation – A coroutine that proceeds with the invocation by executing the next interceptor in the chain or invoking the actual RPC on the underlying Channel. It is the interceptor’s responsibility to call it if it decides to move the RPC forward. The interceptor can use call = await continuation(client_call_details, request) to continue with the RPC. continuation returns the call to the RPC.
client_call_details – A ClientCallDetails object describing the outgoing RPC.
request – The request value for the RPC.
- Returns:
The RPC Call or an asynchronous iterator.
- Raises:
AioRpcError – Indicating that the RPC terminated with non-OK status.
asyncio.CancelledError – Indicating that the RPC was canceled.
- class buildgrid.server.client.interceptors.AsyncStreamUnaryInterceptor(func: InterceptorFunc)
Bases:
StreamUnaryClientInterceptor
- async intercept_stream_unary(continuation, client_call_details, request_iterator)
Intercepts a stream-unary invocation asynchronously.
Within the interceptor the usage of the call methods like write or even awaiting the call should be done carefully, since the caller could be expecting an untouched call, for example for start writing messages to it.
- Parameters:
continuation – A coroutine that proceeds with the invocation by executing the next interceptor in the chain or invoking the actual RPC on the underlying Channel. It is the interceptor’s responsibility to call it if it decides to move the RPC forward. The interceptor can use call = await continuation(client_call_details, request_iterator) to continue with the RPC. continuation returns the call to the RPC.
client_call_details – A ClientCallDetails object describing the outgoing RPC.
request_iterator – The request iterator that will produce requests for the RPC.
- Returns:
The RPC Call.
- Raises:
AioRpcError – Indicating that the RPC terminated with non-OK status.
asyncio.CancelledError – Indicating that the RPC was canceled.
- class buildgrid.server.client.interceptors.AsyncStreamStreamInterceptor(func: InterceptorFunc)
Bases:
StreamStreamClientInterceptor
- async intercept_stream_stream(continuation, client_call_details, request_iterator)
Intercepts a stream-stream invocation asynchronously.
Within the interceptor the usage of the call methods like write or even awaiting the call should be done carefully, since the caller could be expecting an untouched call, for example for start writing messages to it.
The function could return the call object or an asynchronous iterator, in case of being an asyncrhonous iterator this will become the source of the reads done by the caller.
- Parameters:
continuation – A coroutine that proceeds with the invocation by executing the next interceptor in the chain or invoking the actual RPC on the underlying Channel. It is the interceptor’s responsibility to call it if it decides to move the RPC forward. The interceptor can use call = await continuation(client_call_details, request_iterator) to continue with the RPC. continuation returns the call to the RPC.
client_call_details – A ClientCallDetails object describing the outgoing RPC.
request_iterator – The request iterator that will produce requests for the RPC.
- Returns:
The RPC Call or an asynchronous iterator.
- Raises:
AioRpcError – Indicating that the RPC terminated with non-OK status.
asyncio.CancelledError – Indicating that the RPC was canceled.