The runner-to-runner protocol.
Attributes#
| Attribute | Type | Description |
|---|---|---|
ping | = make_rpc('Ping') | |
notify | = make_rpc('Notify', payload=(S.Struct(NotifyPayload, envelope=(envelope_.PartialSchema))), error=_errors) | |
effect | = make_rpc('Effect', payload=(S.Struct(RequestPayload, request=(envelope_.PartialRequestSchema))), success=ReplyEncodedSchema, error=_errors) | |
stream | = make_rpc('Stream', payload=(S.Struct(RequestPayload, request=(envelope_.PartialRequestSchema))), success=ReplyEncodedSchema, error=_errors, stream=True) | |
envelope | = make_rpc('Envelope', payload=(S.Struct(EnvelopePayload, envelope=(S.Union(envelope_.AckChunkSchema, envelope_.InterruptSchema)))), error=_errors) |
Functions#
handlers#
handlers() -> Handlers[Self, Never, Tags_contra]No handlers yet: add one per RPC with handle.
Returns Handlers[Self, Never, Tags_contra]
@classmethod
def handlers(cls) -> Handlers[Self, Never, Tags_contra]:
"""No handlers yet: add one per RPC with ``handle``."""
return Handlers(cls, {})to_layer#
to_layer[R](handlers) -> Layer[HandlersFor[Self], Never, R]The layer of the group's handlers (Effect's toLayer). Each
handler runs with the services of the layer's context. An RPC left
without a handler is a pyright error when the group lists its tags
(RpcGroup[Literal[...]]), and a ValueError here either way.
| Parameter | Type | Description |
|---|---|---|
handlers | Handlers[Self, R, Never] |
Returns Layer[HandlersFor[Self], Never, R]
@classmethod
def to_layer[R](
cls, handlers: Handlers[Self, R, Never], /
) -> Layer[HandlersFor[Self], Never, R]:
"""The layer of the group's handlers (Effect's ``toLayer``). Each
handler runs with the services of the layer's context. An RPC left
without a handler is a pyright error when the group lists its tags
(``RpcGroup[Literal[...]]``), and a ``ValueError`` here either way."""
message = cls._missing_handlers(handlers)
if message is not None:
raise ValueError(message)
return cls.to_layer_effect(succeed(handlers))to_layer_effect#
to_layer_effect[EX, RR = Never](handlers) -> Layer[HandlersFor[Self], EX, RR]to_layer with the handlers made by an effect.
| Parameter | Type | Description |
|---|---|---|
handlers | Effect[Handlers[Self, RR, Never], EX, RR] |
Returns Layer[HandlersFor[Self], EX, RR]
@classmethod
def to_layer_effect[EX, RR = Never](
cls, handlers: Effect[Handlers[Self, RR, Never], EX, RR], /
) -> Layer[HandlersFor[Self], EX, RR]:
"""``to_layer`` with the handlers made by an effect."""
require_effect(handlers, "handlers")
return layer_effect_context(handlers.flat_map(cls._handler_context))