pynenc.state_backend.redis_state_backend#

Module Contents#

Classes#

RedisStateBackend

A Redis-based implementation of the state backend.

API#

class pynenc.state_backend.redis_state_backend.RedisStateBackend(app: pynenc.app.Pynenc)[source]#

Bases: pynenc.state_backend.base_state_backend.BaseStateBackend

A Redis-based implementation of the state backend.

This backend uses Redis to store and retrieve the state of invocations, including their data, history, results, and exceptions. It’s suitable for distributed systems where shared state management is required.

Initialization

conf() pynenc.conf.config_state_backend.ConfigStateBackendRedis#
purge() None[source]#

Clears all data from the Redis backend for the current app.app_id.

_upsert_invocation(invocation: pynenc.invocation.dist_invocation.DistributedInvocation) None[source]#

Inserts or updates an invocation in Redis.

Parameters:

invocation (DistributedInvocation) – The invocation object to upsert.

_get_invocation(invocation_id: str) DistributedInvocation[Params, Result][source]#

Retrieves an invocation from Redis by its ID.

Parameters:

invocation_id (DistributedInvocation) – The ID of the invocation to retrieve.

Returns:

The retrieved invocation object.

_add_history(invocation: pynenc.invocation.dist_invocation.DistributedInvocation, invocation_history: pynenc.state_backend.base_state_backend.InvocationHistory) None[source]#

Adds a history record to an invocation in Redis.

Parameters:
_get_history(invocation: DistributedInvocation[Params, Result]) list[pynenc.state_backend.base_state_backend.InvocationHistory][source]#

Retrieves the history of an invocation from Redis.

Parameters:

invocation (DistributedInvocation) – The invocation to get the history for.

Returns:

A list of invocation history records.

_set_result(invocation: DistributedInvocation[Params, Result], result: pynenc.types.Result) None[source]#

Sets the result for an invocation in Redis.

Parameters:
  • invocation (DistributedInvocation) – The invocation to set the result for.

  • result (Result) – The result of the invocation.

_get_result(invocation: DistributedInvocation[Params, Result]) pynenc.types.Result[source]#

Retrieves the result of an invocation from Redis.

Parameters:

invocation (DistributedInvocation) – The invocation to get the result for.

Returns:

The result of the invocation.

_set_exception(invocation: DistributedInvocation[Params, Result], exception: Exception) None[source]#

Sets the exception for an invocation in Redis.

Parameters:
_get_exception(invocation: DistributedInvocation[Params, Result]) Exception[source]#

Retrieves the exception of an invocation from Redis.

Parameters:

invocation (DistributedInvocation) – The invocation to get the exception for.

Returns:

The exception of the invocation.