A cluster runner whose RPCs travel over HTTP or WebSockets (Effect's
HttpRunner).
layer_client_protocol_http / layer_client_protocol_websocket dial
other runners at http(s)://host:port/path / ws(s)://host:port/path;
to_http_effect / to_http_effect_websocket serve the runner protocol
as an HTTP handler; layer_http_options / layer_websocket_options
add it to the HttpRouter, and layer_http / layer_websocket
serve it at / on the HttpServer. The *_client_only layers join
the cluster as a sender only.
Values#
| Attribute | Type | Description |
|---|---|---|
layer_client_protocol_http_default | Layer[RpcClientProtocol, Never, RpcSerialization | HttpClient] |
|
layer_client_protocol_websocket_default | Layer[RpcClientProtocol, Never, RpcSerialization | WebSocketConstructor] |
|
to_http_effect | Effect[HttpEffect, Never, Scope | RpcSerialization | Sharding | MessageStorage] | The runner protocol served as an HTTP handler of POSTs, its server
running in the current scope (Effect's |
to_http_effect_websocket | Effect[HttpEffect, Never, Scope | RpcSerialization | Sharding | MessageStorage] |
|
layer_client | Layer[Sharding | Runners, Never, ShardingConfig | RpcClientProtocol | MessageStorage | RunnerStorage | RunnerHealth] |
|
layer_http | Layer[Sharding | Runners, Never, RpcSerialization | ShardingConfig | HttpClient | HttpServer | MessageStorage | RunnerStorage | RunnerHealth] | A runner serving at |
layer_http_client_only | Layer[Sharding | Runners, Never, RpcSerialization | ShardingConfig | HttpClient | MessageStorage | RunnerStorage] | A sender-only member of the cluster, dialing runners over HTTP. |
layer_websocket | Layer[Sharding | Runners, Never, RpcSerialization | ShardingConfig | WebSocketConstructor | HttpServer | MessageStorage | RunnerStorage | RunnerHealth] | A runner serving WebSockets at |
layer_websocket_client_only | Layer[Sharding | Runners, Never, RpcSerialization | ShardingConfig | WebSocketConstructor | MessageStorage | RunnerStorage] | A sender-only member of the cluster, dialing runners over WebSockets. |
Functions#
layer_client_protocol_http#
layer_client_protocol_http(*, path, https=False) -> Layer[RpcClientProtocol, Never, RpcSerialization | HttpClient]Dial runners over HTTP POSTs to path (https for TLS).
| Parameter | Type | Description |
|---|---|---|
path | str | |
https | bool = False |
Returns Layer[RpcClientProtocol, Never, RpcSerialization | HttpClient]
def layer_client_protocol_http(
*, path: str, https: bool = False
) -> Layer[RpcClientProtocol, Never, RpcSerialization | HttpClient]:
"""Dial runners over HTTP POSTs to ``path`` (``https`` for TLS)."""
@gen
def make_():
serialization = yield from RpcSerialization()
client = yield from HttpClient()
return _http_client_protocol(serialization, client, path, https)
return layer_.effect(RpcClientProtocol, make_)layer_client_protocol_websocket#
layer_client_protocol_websocket(*, path, https=False) -> Layer[RpcClientProtocol, Never, RpcSerialization | WebSocketConstructor]Dial runners over WebSockets at path (https for wss).
| Parameter | Type | Description |
|---|---|---|
path | str | |
https | bool = False |
Returns Layer[RpcClientProtocol, Never, RpcSerialization | WebSocketConstructor]
def layer_client_protocol_websocket(
*, path: str, https: bool = False
) -> Layer[RpcClientProtocol, Never, RpcSerialization | WebSocketConstructor]:
"""Dial runners over WebSockets at ``path`` (``https`` for ``wss``)."""
@gen
def make_():
serialization = yield from RpcSerialization()
constructor = yield from WebSocketConstructor()
def make_protocol(address: RunnerAddress) -> Effect[ClientProtocolService, Never, Scope]:
@gen
def connect():
url = _url("wss" if https else "ws", address, path)
socket = yield from make_web_socket(url).pipe(
provide_service(WebSocketConstructor, constructor)
)
return (
yield from make_protocol_socket()
.pipe(provide_service(Socket, socket))
.pipe(provide_service(RpcSerialization, serialization))
)
return connect
return RpcClientProtocolService(make=make_protocol, codec_for=serialization.codec_for)
return layer_.effect(RpcClientProtocol, make_)layer_http_options#
layer_http_options(*, path) -> Layer[Sharding | Runners, Never, _ServerNeeds | HttpRouter]A runner serving the runner protocol on POSTs to path of the
HttpRouter.
| Parameter | Type | Description |
|---|---|---|
path | str |
Returns Layer[Sharding | Runners, Never, _ServerNeeds | HttpRouter]
def layer_http_options(*, path: str) -> Layer[Sharding | Runners, Never, _ServerNeeds | HttpRouter]:
"""A runner serving the runner protocol on POSTs to ``path`` of the
``HttpRouter``."""
return runner_server.layer_with_clients.pipe(layer_.provide(layer_protocol_http(path)))layer_websocket_options#
layer_websocket_options(*, path) -> Layer[Sharding | Runners, Never, _ServerNeeds | HttpRouter]A runner serving the runner protocol on WebSockets at path of the
HttpRouter.
| Parameter | Type | Description |
|---|---|---|
path | str |
Returns Layer[Sharding | Runners, Never, _ServerNeeds | HttpRouter]
def layer_websocket_options(
*, path: str
) -> Layer[Sharding | Runners, Never, _ServerNeeds | HttpRouter]:
"""A runner serving the runner protocol on WebSockets at ``path`` of the
``HttpRouter``."""
return runner_server.layer_with_clients.pipe(layer_.provide(layer_protocol_websocket(path)))