streaming
frequenz.client.base.streaming ¤
Implementation of the grpc streaming helper.
Attributes¤
frequenz.client.base.streaming.InputT
module-attribute
¤
InputT = TypeVar('InputT')
The input type of the stream.
frequenz.client.base.streaming.OutputT
module-attribute
¤
OutputT = TypeVar('OutputT')
The output type of the stream.
Classes¤
frequenz.client.base.streaming.GrpcStreamBroadcaster ¤
Bases: Generic[InputT, OutputT]
Helper class to handle grpc streaming methods.
Source code in frequenz/client/base/streaming.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
Attributes¤
is_running
property
¤
is_running: bool
Return whether the streaming helper is running.
RETURNS | DESCRIPTION |
---|---|
bool
|
Whether the streaming helper is running. |
Functions¤
__init__ ¤
__init__(
stream_name: str,
stream_method: Callable[[], AsyncIterable[InputT]],
transform: Callable[[InputT], OutputT],
retry_strategy: Strategy | None = None,
retry_on_exhausted_stream: bool = False,
)
Initialize the streaming helper.
PARAMETER | DESCRIPTION |
---|---|
stream_name
|
A name to identify the stream in the logs.
TYPE:
|
stream_method
|
A function that returns the grpc stream. This function is called everytime the connection is lost and we want to retry.
TYPE:
|
transform
|
A function to transform the input type to the output type. |
retry_strategy
|
The retry strategy to use, when the connection is lost. Defaults to retries every 3 seconds, with a jitter of 1 second, indefinitely.
TYPE:
|
retry_on_exhausted_stream
|
Whether to retry when the stream is exhausted, i.e. when the server closes the stream. Defaults to False.
TYPE:
|
Source code in frequenz/client/base/streaming.py
new_receiver ¤
stop
async
¤
Stop the streaming helper.