pynenc.state_backend.mem_state_backend#

Module Contents#

Classes#

MemStateBackend

A memory-based implementation of the state backend.

API#

class pynenc.state_backend.mem_state_backend.MemStateBackend(app: pynenc.app.Pynenc)[source]#

Bases: pynenc.state_backend.base_state_backend.BaseStateBackend

A memory-based implementation of the state backend.

Stores invocation data, history, results, and exceptions in in-memory dictionaries. Useful for environments where persistence is not required or for testing purposes.

Warning

The MemStateBackend class stores all data in the process’s memory and is not suitable for production systems. Its use should be limited to testing or demonstration purposes only.

Initialization

purge() None[source]#

Clears all stored data

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

Inserts or updates an invocation in the memory cache.

Parameters:

invocation (DistributedInvocation) – The invocation object to upsert.

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

Retrieves an invocation from the memory cache by its ID.

Parameters:

invocation_id (str) – 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.

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

Retrieves the history of an invocation.

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.

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

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

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

Sets the exception for an invocation.

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

Retrieves the result of an invocation.

Parameters:

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

Returns:

The result of the invocation.

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

Retrieves the exception of an invocation.

Parameters:

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

Returns:

The exception of the invocation.