Where the cluster's runners register and lock their shards
(Effect's RunnerStorage). copy.replace(storage, acquire=...)
swaps an operation.
Attributes#
| Attribute | Type | Description |
|---|---|---|
get_runners | Effect[list[tuple[Runner, bool]], PersistenceError] | Every registered runner with whether it is healthy (a stored
runner that does not decode is skipped). Fails with
|
Functions#
__init__#
__init__(*, register, unregister, get_runners, set_runner_health, acquire, refresh, release, release_all) -> None| Parameter | Type | Description |
|---|---|---|
register | Callable[[Runner, bool], Effect[MachineId, PersistenceError]] | |
unregister | Callable[[RunnerAddress], Effect[None, PersistenceError]] | |
get_runners | Effect[list[tuple[Runner, bool]], PersistenceError] | |
set_runner_health | Callable[[RunnerAddress, bool], Effect[None, PersistenceError]] | |
acquire | Callable[[RunnerAddress, Iterable[ShardId]], Effect[list[ShardId], PersistenceError]] | |
refresh | Callable[[RunnerAddress, Iterable[ShardId]], Effect[list[ShardId], PersistenceError]] | |
release | Callable[[RunnerAddress, ShardId], Effect[None, PersistenceError]] | |
release_all | Callable[[RunnerAddress], Effect[None, PersistenceError]] |
def __init__(
self,
*,
register: Callable[[Runner, bool], Effect[MachineId, PersistenceError]],
unregister: Callable[[RunnerAddress], Effect[None, PersistenceError]],
get_runners: Effect[list[tuple[Runner, bool]], PersistenceError],
set_runner_health: Callable[[RunnerAddress, bool], Effect[None, PersistenceError]],
acquire: Callable[
[RunnerAddress, Iterable[ShardId]], Effect[list[ShardId], PersistenceError]
],
refresh: Callable[
[RunnerAddress, Iterable[ShardId]], Effect[list[ShardId], PersistenceError]
],
release: Callable[[RunnerAddress, ShardId], Effect[None, PersistenceError]],
release_all: Callable[[RunnerAddress], Effect[None, PersistenceError]],
) -> None:
self._register = register
self._unregister = unregister
self._get_runners = get_runners
self._set_runner_health = set_runner_health
self._acquire = acquire
self._refresh = refresh
self._release = release
self._release_all = release_allregister#
register(runner, healthy) -> Effect[MachineId, PersistenceError]Registers runner (replacing one at its address) with its
health, and gives the machine id it is assigned. Fails with
PersistenceError when the storage cannot be written.
| Parameter | Type | Description |
|---|---|---|
runner | Runner | |
healthy | bool |
Returns Effect[MachineId, PersistenceError]
def register(self, runner: Runner, healthy: bool) -> Effect[MachineId, PersistenceError]:
"""Registers ``runner`` (replacing one at its address) with its
health, and gives the machine id it is assigned. Fails with
``PersistenceError`` when the storage cannot be written."""
return self._register(runner, healthy)unregister#
unregister(address) -> Effect[None, PersistenceError]Removes the runner at address. Fails with
PersistenceError when the storage cannot be written.
| Parameter | Type | Description |
|---|---|---|
address | RunnerAddress |
Returns Effect[None, PersistenceError]
def unregister(self, address: RunnerAddress) -> Effect[None, PersistenceError]:
"""Removes the runner at ``address``. Fails with
``PersistenceError`` when the storage cannot be written."""
return self._unregister(address)set_runner_health#
set_runner_health(address, healthy) -> Effect[None, PersistenceError]Records whether the runner at address is healthy. Fails with
PersistenceError when the storage cannot be written.
| Parameter | Type | Description |
|---|---|---|
address | RunnerAddress | |
healthy | bool |
Returns Effect[None, PersistenceError]
def set_runner_health(
self, address: RunnerAddress, healthy: bool
) -> Effect[None, PersistenceError]:
"""Records whether the runner at ``address`` is healthy. Fails with
``PersistenceError`` when the storage cannot be written."""
return self._set_runner_health(address, healthy)acquire#
acquire(address, shard_ids) -> Effect[list[ShardId], PersistenceError]Takes for the runner at address the locks it can of
shard_ids, and gives back the shards it now holds. Fails with
PersistenceError when the storage cannot be written.
| Parameter | Type | Description |
|---|---|---|
address | RunnerAddress | |
shard_ids | Iterable[ShardId] |
Returns Effect[list[ShardId], PersistenceError]
def acquire(
self, address: RunnerAddress, shard_ids: Iterable[ShardId]
) -> Effect[list[ShardId], PersistenceError]:
"""Takes for the runner at ``address`` the locks it can of
``shard_ids``, and gives back the shards it now holds. Fails with
``PersistenceError`` when the storage cannot be written."""
return self._acquire(address, shard_ids)refresh#
refresh(address, shard_ids) -> Effect[list[ShardId], PersistenceError]Extends the locks of shard_ids the runner at address
still holds, and gives back those shards. Fails with
PersistenceError when the storage cannot be written.
| Parameter | Type | Description |
|---|---|---|
address | RunnerAddress | |
shard_ids | Iterable[ShardId] |
Returns Effect[list[ShardId], PersistenceError]
def refresh(
self, address: RunnerAddress, shard_ids: Iterable[ShardId]
) -> Effect[list[ShardId], PersistenceError]:
"""Extends the locks of ``shard_ids`` the runner at ``address``
still holds, and gives back those shards. Fails with
``PersistenceError`` when the storage cannot be written."""
return self._refresh(address, shard_ids)release#
release(address, shard_id) -> Effect[None, PersistenceError]Releases the lock the runner at address holds on
shard_id. Fails with PersistenceError when the storage
cannot be written.
| Parameter | Type | Description |
|---|---|---|
address | RunnerAddress | |
shard_id | ShardId |
Returns Effect[None, PersistenceError]
def release(self, address: RunnerAddress, shard_id: ShardId) -> Effect[None, PersistenceError]:
"""Releases the lock the runner at ``address`` holds on
``shard_id``. Fails with ``PersistenceError`` when the storage
cannot be written."""
return self._release(address, shard_id)release_all#
release_all(address) -> Effect[None, PersistenceError]Releases every shard lock the runner at address holds. Fails
with PersistenceError when the storage cannot be written.
| Parameter | Type | Description |
|---|---|---|
address | RunnerAddress |
Returns Effect[None, PersistenceError]
def release_all(self, address: RunnerAddress) -> Effect[None, PersistenceError]:
"""Releases every shard lock the runner at ``address`` holds. Fails
with ``PersistenceError`` when the storage cannot be written."""
return self._release_all(address)