class documentation

class ExtractorChannel(GRPCChannel): (source)

View In Hierarchy

Extract service names from gRPC stub classes.

This channel records the last method that a stub calls. It gets the service name from that method and does not make a network request.

Async Method __aenter__ Enter the asynchronous context.
Async Method __aexit__ Exit the asynchronous context.
Method __init__ Undocumented
Async Method channel_ready Return immediately because this introspection channel is ready.
Async Method close Return without an action because this channel has no connection.
Method get_service_name Return the service name from the last recorded method.
Method get_state Return READY for this introspection channel.
Method stream_stream Record a stream-stream method call and return a stub.
Method stream_unary Record a stream-unary method call and return a stub.
Method unary_stream Record a unary-stream method call and return a stub.
Method unary_unary Record a unary-unary method call and return a stub.
Async Method wait_for_state_change Reject a state-change wait for this introspection channel.
Instance Variable _last_method Undocumented
async def __aenter__(self) -> ExtractorChannel: (source)

Enter the asynchronous context.

Returns
ExtractorChannelSelf.
async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any): (source)

Exit the asynchronous context.

Parameters
exc_type:AnyException type.
exc_val:AnyException value.
exc_tb:AnyException traceback.
def __init__(self): (source)

Undocumented

async def channel_ready(self): (source)

Return immediately because this introspection channel is ready.

async def close(self, grace: float | None = None): (source)

Return without an action because this channel has no connection.

Parameters
grace:float or NoneOptional grace period.
def get_service_name(self) -> str: (source)

Return the service name from the last recorded method.

Returns
strThe service name.
Raises
NoMethodsInServiceErrorIf no methods have been recorded.
def get_state(self, try_to_connect: bool = False) -> ChannelConnectivity: (source)

Return READY for this introspection channel.

Parameters
try_to_connect:boolWhether to attempt connection.
Returns
ChannelConnectivityThe connectivity state.
def stream_stream(self, method: str, request_serializer: SerializingFunction | None = None, response_deserializer: DeserializingFunction | None = None, _registered_method: bool | None = None) -> StreamStreamMultiCallable: (source)

Record a stream-stream method call and return a stub.

Parameters
method:strThe method name.
request_serializer:SerializingFunction or NoneOptional request serializer.
response_deserializer:DeserializingFunction or NoneOptional response deserializer.
_registered_method:bool or NoneWhether the method is registered.
Returns
StreamStreamMultiCallableA stub callable.
def stream_unary(self, method: str, request_serializer: SerializingFunction | None = None, response_deserializer: DeserializingFunction | None = None, _registered_method: bool | None = None) -> StreamUnaryMultiCallable: (source)

Record a stream-unary method call and return a stub.

Parameters
method:strThe method name.
request_serializer:SerializingFunction or NoneOptional request serializer.
response_deserializer:DeserializingFunction or NoneOptional response deserializer.
_registered_method:bool or NoneWhether the method is registered.
Returns
StreamUnaryMultiCallableA stub callable.
def unary_stream(self, method: str, request_serializer: SerializingFunction | None = None, response_deserializer: DeserializingFunction | None = None, _registered_method: bool | None = None) -> UnaryStreamMultiCallable[Req, Res]: (source)

Record a unary-stream method call and return a stub.

Parameters
method:strThe method name.
request_serializer:SerializingFunction or NoneOptional request serializer.
response_deserializer:DeserializingFunction or NoneOptional response deserializer.
_registered_method:bool or NoneWhether the method is registered.
Returns
UnaryStreamMultiCallableA stub callable.
def unary_unary(self, method: str, request_serializer: SerializingFunction | None = None, response_deserializer: DeserializingFunction | None = None, _registered_method: bool | None = False) -> UnaryUnaryMultiCallable[Req, Res]: (source)

Record a unary-unary method call and return a stub.

Parameters
method:strThe method name.
request_serializer:SerializingFunction or NoneOptional request serializer.
response_deserializer:DeserializingFunction or NoneOptional response deserializer.
_registered_method:bool or NoneWhether the method is registered.
Returns
UnaryUnaryMultiCallableA stub callable.
async def wait_for_state_change(self, last_observed_state: ChannelConnectivity): (source)

Reject a state-change wait for this introspection channel.

Parameters
last_observed_state:ChannelConnectivityThe last observed state.
Raises
NotImplementedErrorAlways raised.
_last_method = (source)

Undocumented