peyk.fsm.storage.isolation

FSM event isolation primitives.

Classes

BaseEventIsolation()

Serialize handlers that share one StorageKey.

DisabledEventIsolation()

Do not serialize events.

RedisEventIsolation(redis, *[, key_builder, ...])

Serialize events using Redis distributed locks.

RedisLock(*args, **kwargs)

RedisLock provides the FSM API surface used by peyk.

RedisLockClient(*args, **kwargs)

RedisLockClient provides the FSM API surface used by peyk.

SimpleEventIsolation()

Serialize by key and evict idle locks after release.

class peyk.fsm.storage.isolation.BaseEventIsolation[source]

Bases: object

Serialize handlers that share one StorageKey.

lock(key: StorageKey) AsyncIterator[None][source]

Return an async context manager for the event lock.

async close() None[source]

Close isolation resources.

class peyk.fsm.storage.isolation.DisabledEventIsolation[source]

Bases: BaseEventIsolation

Do not serialize events.

lock(key: StorageKey) AsyncIterator[None][source]

Performs the lock operation for the FSM client.

Parameters:

key – Value used by this operation.

Returns:

Result produced by the FSM operation.

class peyk.fsm.storage.isolation.SimpleEventIsolation[source]

Bases: BaseEventIsolation

Serialize by key and evict idle locks after release.

lock(key: StorageKey) AsyncIterator[None][source]

Performs the lock operation for the FSM client.

Parameters:

key – Value used by this operation.

Returns:

Result produced by the FSM operation.

async close() None[source]

Performs the close operation for the FSM client.

class peyk.fsm.storage.isolation.RedisLock(*args, **kwargs)[source]

Bases: Protocol

RedisLock provides the FSM API surface used by peyk.

async acquire() bool[source]

Performs the acquire operation for the FSM client.

Returns:

Result produced by the FSM operation.

async release() None[source]

Performs the release operation for the FSM client.

class peyk.fsm.storage.isolation.RedisLockClient(*args, **kwargs)[source]

Bases: Protocol

RedisLockClient provides the FSM API surface used by peyk.

lock(name: str, timeout: float | None = None, sleep: float = 0.1, blocking: bool = True, blocking_timeout: float | None = None) RedisLock[source]

Performs the lock operation for the FSM client.

Parameters:
  • name – Value used by this operation.

  • timeout – Maximum time to wait for the operation.

  • sleep – Value used by this operation.

  • blocking – Value used by this operation.

  • blocking_timeout – Value used by this operation.

Returns:

Result produced by the FSM operation.

async aclose() None[source]

Performs the aclose operation for the FSM client.

class peyk.fsm.storage.isolation.RedisEventIsolation(redis: RedisLockClient, *, key_builder: KeyBuilder | None = None, lock_timeout: float | None = 30.0, blocking_timeout: float | None = None)[source]

Bases: BaseEventIsolation

Serialize events using Redis distributed locks.

lock(key: StorageKey) AsyncIterator[None][source]

Performs the lock operation for the FSM client.

Parameters:

key – Value used by this operation.

Returns:

Result produced by the FSM operation.

async close() None[source]

Performs the close operation for the FSM client.