GitHub

RpcGroupWith

API reference for RpcGroupWith.

A group whose RPCs are all wrapped by GM (Effect's RpcGroup.middleware)::

class Users(RpcGroupWith[Auth]):
    get = rpc.make("Users.get", ...)

It wraps every RPC of the class: its own, those it merges from other groups (class Api(Users, RpcGroupWith[Auth])) and those of its subclasses. RpcGroupWith[A | B] wraps them in A then B.

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.

ParameterTypeDescription
handlersHandlers[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.

ParameterTypeDescription
handlersEffect[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))