One runner whose messages are kept in SQL (Effect's SingleRunner):
sharding with no other runners, settings read from the environment.
Functions#
layer#
layer(*, sharding_config=None, runner_storage_kind='sql') -> Layer[Sharding | Runners | MessageStorage, ConfigError, SqlClient]Sharding of one runner over SqlMessageStorage; runner storage in
SQL (or in memory), settings from the environment passed through
sharding_config.
| Parameter | Type | Description |
|---|---|---|
sharding_config | Callable[[ShardingConfigService], ShardingConfigService] | None = None | |
runner_storage_kind | Literal['memory', 'sql'] = 'sql' |
Returns Layer[Sharding | Runners | MessageStorage, ConfigError, SqlClient]
def layer(
*,
sharding_config: Callable[[ShardingConfigService], ShardingConfigService] | None = None,
runner_storage_kind: Literal["memory", "sql"] = "sql",
) -> Layer[Sharding | Runners | MessageStorage, ConfigError, SqlClient]:
"""Sharding of one runner over ``SqlMessageStorage``; runner storage in
SQL (or in memory), settings from the environment passed through
``sharding_config``."""
locks = (
runner_storage.layer_memory
if runner_storage_kind == "memory"
else sql_runner_storage.layer.or_die()
)
return (
sharding.layer.pipe(layer_.provide_merge(runners.layer_noop))
.pipe(layer_.provide_merge(sql_message_storage.layer))
.pipe(layer_.provide(layer_.merge(locks, runner_health.layer_noop)))
.pipe(layer_.provide(sharding_config_.layer_from_env(sharding_config)))
)