GitHub

cluster_http

API reference for cluster_http.

Cluster runners over HTTP or WebSockets (Effect's NodeClusterHttp).

layer(transport="http" | "websocket") is a whole runner: the live HTTP server at the configured runner_listen_address (or runner_address) serving the runner protocol at /, other runners dialed with httpx (extra pyfect-dev[httpx]) or websockets (extra pyfect-dev[websockets]), and the health, storage, settings and serialization options of cluster_socket.layer.

Values

AttributeTypeDescription
layer_http_serverLayer[HttpServer | Path | HttpPlatform | FileSystem | Generator, SocketServerError, ShardingConfig]

The live HTTP server (and its platform services) at the runner's listen address.

layer_k8s_http_clientLayer[K8sHttpClient]

The K8sHttpClient of a pod: httpx trusting the service account's CA when it is mounted (Effect's layerK8sHttpClient).

Types

TypeDefinitionDescription
Transporttype Transport = Literal['http', 'websocket']

Functions

layer

layer(*, transport: Transport, client_only: Literal[False] = False, storage: Literal['sql'] = 'sql', runner_health: Health = 'ping', runner_health_k8s_namespace: str | None = None, runner_health_k8s_label_selector: str | None = None, serialization: SerializationKind = ..., serialization_max_buffer_size: MaxBufferSize = ..., sharding_config: ShardingConfigUpdate | None = None) -> Layer[_Out, SocketServerError | ConfigError, SqlClient]
layer(*, transport: Transport, client_only: Literal[False] = False, storage: Literal['local'], runner_health: Health = 'ping', runner_health_k8s_namespace: str | None = None, runner_health_k8s_label_selector: str | None = None, serialization: SerializationKind = ..., serialization_max_buffer_size: MaxBufferSize = ..., sharding_config: ShardingConfigUpdate | None = None) -> Layer[_Out, SocketServerError | ConfigError]
layer(*, transport: Transport, client_only: Literal[False] = False, storage: Literal['byo'], runner_health: Health = 'ping', runner_health_k8s_namespace: str | None = None, runner_health_k8s_label_selector: str | None = None, serialization: SerializationKind = ..., serialization_max_buffer_size: MaxBufferSize = ..., sharding_config: ShardingConfigUpdate | None = None) -> Layer[_Core, SocketServerError | ConfigError, MessageStorage | RunnerStorage]
layer(*, transport: Transport, client_only: Literal[True], storage: Literal['sql'] = 'sql', serialization: SerializationKind = ..., serialization_max_buffer_size: MaxBufferSize = ..., sharding_config: ShardingConfigUpdate | None = None) -> Layer[_Out, ConfigError, SqlClient]
layer(*, transport: Transport, client_only: Literal[True], storage: Literal['local'], serialization: SerializationKind = ..., serialization_max_buffer_size: MaxBufferSize = ..., sharding_config: ShardingConfigUpdate | None = None) -> Layer[_Out, ConfigError]
layer(*, transport: Transport, client_only: Literal[True], storage: Literal['byo'], serialization: SerializationKind = ..., serialization_max_buffer_size: MaxBufferSize = ..., sharding_config: ShardingConfigUpdate | None = None) -> Layer[_Core, ConfigError, MessageStorage | RunnerStorage]

A cluster runner (or, with client_only, a sender) over HTTP or WebSockets.

ParameterTypeDescription
transport
client_only= False
storage= 'sql'
runner_health= 'ping'
runner_health_k8s_namespace= None
runner_health_k8s_label_selector= None
serialization= 'binary'
serialization_max_buffer_size= 16 * 1024 * 1024
sharding_config= None
@overload
def layer(
    *,
    transport: Transport,
    client_only: Literal[False] = False,
    storage: Literal["sql"] = "sql",
    runner_health: Health = "ping",
    runner_health_k8s_namespace: str | None = None,
    runner_health_k8s_label_selector: str | None = None,
    serialization: SerializationKind = ...,
    serialization_max_buffer_size: MaxBufferSize = ...,
    sharding_config: ShardingConfigUpdate | None = None,
) -> Layer[_Out, SocketServerError | ConfigError, SqlClient]: ...
@overload
def layer(
    *,
    transport: Transport,
    client_only: Literal[False] = False,
    storage: Literal["local"],
    runner_health: Health = "ping",
    runner_health_k8s_namespace: str | None = None,
    runner_health_k8s_label_selector: str | None = None,
    serialization: SerializationKind = ...,
    serialization_max_buffer_size: MaxBufferSize = ...,
    sharding_config: ShardingConfigUpdate | None = None,
) -> Layer[_Out, SocketServerError | ConfigError]: ...
@overload
def layer(
    *,
    transport: Transport,
    client_only: Literal[False] = False,
    storage: Literal["byo"],
    runner_health: Health = "ping",
    runner_health_k8s_namespace: str | None = None,
    runner_health_k8s_label_selector: str | None = None,
    serialization: SerializationKind = ...,
    serialization_max_buffer_size: MaxBufferSize = ...,
    sharding_config: ShardingConfigUpdate | None = None,
) -> Layer[_Core, SocketServerError | ConfigError, MessageStorage | RunnerStorage]: ...
@overload
def layer(
    *,
    transport: Transport,
    client_only: Literal[True],
    storage: Literal["sql"] = "sql",
    serialization: SerializationKind = ...,
    serialization_max_buffer_size: MaxBufferSize = ...,
    sharding_config: ShardingConfigUpdate | None = None,
) -> Layer[_Out, ConfigError, SqlClient]: ...
@overload
def layer(
    *,
    transport: Transport,
    client_only: Literal[True],
    storage: Literal["local"],
    serialization: SerializationKind = ...,
    serialization_max_buffer_size: MaxBufferSize = ...,
    sharding_config: ShardingConfigUpdate | None = None,
) -> Layer[_Out, ConfigError]: ...
@overload
def layer(
    *,
    transport: Transport,
    client_only: Literal[True],
    storage: Literal["byo"],
    serialization: SerializationKind = ...,
    serialization_max_buffer_size: MaxBufferSize = ...,
    sharding_config: ShardingConfigUpdate | None = None,
) -> Layer[_Core, ConfigError, MessageStorage | RunnerStorage]: ...
def layer(
    *,
    transport: Transport,
    client_only: bool = False,
    storage: Storage = "sql",
    runner_health: Health = "ping",
    runner_health_k8s_namespace: str | None = None,
    runner_health_k8s_label_selector: str | None = None,
    serialization: SerializationKind = "binary",
    serialization_max_buffer_size: MaxBufferSize = 16 * 1024 * 1024,
    sharding_config: ShardingConfigUpdate | None = None,
) -> Layer[Any, Any, Any]:
    """A cluster runner (or, with ``client_only``, a sender) over HTTP or
    WebSockets."""
    health = (
        None
        if client_only
        else runner_health_layer(
            client_protocol=_client_protocol(transport),
            health=runner_health,
            namespace=runner_health_k8s_namespace,
            label_selector=runner_health_k8s_label_selector,
        )
    )
    return assemble(
        _transport(transport, client_only),
        health=health,
        storage=storage,
        sharding_config=sharding_config,
        serialization_kind=serialization,
        serialization_max_buffer_size=serialization_max_buffer_size,
    )