How a runner shards entities (Effect's ShardingConfig).
DEFAULTS holds Effect's defaults; layer(dataclasses.replace(DEFAULTS, shards_per_group=30)) provides a variation, and config /
layer_from_env read one (HOST, PORT, SHARDS_PER_GROUP, ...
in the environment). Durations are Duration values. "unbounded" for the
mailbox capacity and resident entities is only available in code.
Values#
| Attribute | Type | Description |
|---|---|---|
DEFAULTS | ShardingConfigService | Effect's defaults. |
layer_defaults | layer_.Layer[ShardingConfig] |
|
config | Config[ShardingConfigService] | The settings read from the current config provider, Effect's defaults
for what is absent. Keys are camelCase ( |
Types#
| Type | Definition | Description |
|---|---|---|
Unbounded | type Unbounded = Literal['unbounded'] |
Classes#
Functions#
layer#
layer(settings=DEFAULTS) -> layer_.Layer[ShardingConfig]| Parameter | Type | Description |
|---|---|---|
settings | ShardingConfigService = DEFAULTS |
Returns layer_.Layer[ShardingConfig]
def layer(settings: ShardingConfigService = DEFAULTS) -> layer_.Layer[ShardingConfig]:
return layer_.succeed(ShardingConfig, settings)layer_from_env#
layer_from_env(update=None) -> layer_.Layer[ShardingConfig, ConfigError]The settings read from the environment in CONSTANT_CASE
(SHARDS_PER_GROUP), then passed through update.
| Parameter | Type | Description |
|---|---|---|
update | Callable[[ShardingConfigService], ShardingConfigService] | None = None |
Returns layer_.Layer[ShardingConfig, ConfigError]
def layer_from_env(
update: Callable[[ShardingConfigService], ShardingConfigService] | None = None,
) -> layer_.Layer[ShardingConfig, ConfigError]:
"""The settings read from the environment in CONSTANT_CASE
(``SHARDS_PER_GROUP``), then passed through ``update``."""
read = config.parse(from_env().constant_case())
return layer_.effect(ShardingConfig, read if update is None else read.map(update))shard_group_config#
shard_group_config(settings) -> ShardGroupsThe available groups, and those of them this runner is assigned.
| Parameter | Type | Description |
|---|---|---|
settings | ShardingConfigService |
Returns ShardGroups
def shard_group_config(settings: ShardingConfigService) -> ShardGroups:
"""The available groups, and those of them this runner is assigned."""
available = tuple(sorted(set(settings.available_shard_groups)))
assigned = tuple(g for g in available if g in settings.assigned_shard_groups)
return ShardGroups(available, assigned)