GitHub

ClientProtocolService

API reference for ClientProtocolService.

A client transport (Effect's RpcClient.Protocol): run delivers the responses for a client, send writes its messages. with_run_client builds one from its parts.

Attributes

AttributeTypeDescription
supports_ackbool = supports_ack

Whether the server expects an Ack after each stream chunk.

codec_forCodecFor

codec_for(schema): the codec filling the value holes of the messages for schema, the very function of the RpcSerialization behind this transport (encode caches compare it by identity).

Functions

__init__

__init__(run, send, supports_ack, codec_for) -> None
ParameterTypeDescription
runCallable[[int, WriteResponse], Effect[Never]]
sendCallable[[int, Message], Effect[None, RpcClientError]]
supports_ackbool
codec_forCodecFor
def __init__(
    self,
    run: Callable[[int, WriteResponse], Effect[Never]],
    send: Callable[[int, Message], Effect[None, RpcClientError]],
    supports_ack: bool,
    codec_for: CodecFor,
) -> None:
    self._run = run
    self._send = send
    self.supports_ack = supports_ack
    self._codec_for = codec_for

run

run(client_id, f) -> Effect[Never]

Hands each encoded response for client_id to f, until interrupted (it never returns and never fails).

ParameterTypeDescription
client_idint
fWriteResponse

Returns Effect[Never]

def run(self, client_id: int, f: WriteResponse) -> Effect[Never]:
    """Hands each encoded response for ``client_id`` to ``f``, until
    interrupted (it never returns and never fails)."""
    return self._run(client_id, f)

send

send(client_id, message) -> Effect[None, RpcClientError]

Writes the encoded message of client_id; fails with RpcClientError when the transport cannot write it (and, for a protocol from with_run_client, once its scope has closed).

ParameterTypeDescription
client_idint
messageMessage

Returns Effect[None, RpcClientError]

def send(self, client_id: int, message: Message) -> Effect[None, RpcClientError]:
    """Writes the encoded ``message`` of ``client_id``; fails with
    ``RpcClientError`` when the transport cannot write it (and, for a
    protocol from ``with_run_client``, once its scope has closed)."""
    return self._send(client_id, message)