GitHub

API reference for test.

An in-memory client of a group's handlers (Effect's RpcTest).

make_client(Group, layer=GroupLive) builds the handlers' layer into the caller's Scope, so the handlers' resources (a database, forked workers) stay open while the client is used::

client = yield from rpc_test.make_client(Todos, layer=TodosLive)

Without layer the handlers come from the context, which must then outlive the client: a layer provided to make_client(...) alone is released once the client is made, as in Effect.

Functions

make_client

make_client[G: RpcGroup](group: type[G], *, disable_fatal_defects: bool = False) -> Effect[G, Never, Scope | HandlersFor[G]]
make_client[G: RpcGroup, E, R](group: type[G], *, layer: Layer[HandlersFor[G], E, R], disable_fatal_defects: bool = False) -> Effect[G, E, R | Scope]

A client of group calling its handlers directly, without serialization. The handlers (and middleware) are layer, built into the caller's Scope, or else come from the context; the client is valid until that scope closes.

ParameterTypeDescription
group
layer= None
disable_fatal_defects= False
@overload
def make_client[G: RpcGroup](
    group: type[G], *, disable_fatal_defects: bool = False
) -> Effect[G, Never, Scope | HandlersFor[G]]: ...
@overload
def make_client[G: RpcGroup, E, R](
    group: type[G], *, layer: Layer[HandlersFor[G], E, R], disable_fatal_defects: bool = False
) -> Effect[G, E, R | Scope]: ...
def make_client(
    group: type[RpcGroup],
    *,
    layer: Layer[Any, Any, Any] | None = None,
    disable_fatal_defects: bool = False,
) -> Effect[Any, Any, Any]:
    """A client of ``group`` calling its handlers directly, without
    serialization. The handlers (and middleware) are ``layer``, built into
    the caller's ``Scope``, or else come from the context; the client is
    valid until that scope closes."""
    return with_layer(lambda: _make_client(group, disable_fatal_defects), layer)