dml_util.aws.dynamodb#

DynamoDB state management.

This module provides state management functionality using AWS DynamoDB. It includes classes for storing and retrieving state with locking mechanisms to ensure data consistency in distributed environments.

Classes

DynamoState(cache_key[, run_id, timeout, db, tb])

DynamoDB-based state management.

class dml_util.aws.dynamodb.DynamoState(cache_key, run_id=<factory>, timeout=5, db=<factory>, tb=<factory>)[source]#

Bases: State

DynamoDB-based state management.

This class implements state management using AWS DynamoDB. It provides methods for storing and retrieving state with locking capabilities to ensure data consistency in distributed environments.

Parameters:
  • cache_key (str) – Unique identifier for the state record in DynamoDB.

  • run_id (str, optional) – Unique identifier for the current run, used for locking. Defaults to a random UUID.

  • timeout (int, optional) – Lock timeout in seconds. Defaults to TIMEOUT (5 seconds).

  • db (boto3.client, optional) – DynamoDB client. Defaults to a new client created using get_client.

  • tb (str, optional) – DynamoDB table name. Defaults to the value of the environment variable DYNAMODB_TABLE.

cache_key: str#
db: client#
delete()[source]#

Delete state information.

get(key=None)[source]#
Returns:

None if could not acquire lock {} if there’s no data data otherwise

put(obj)[source]#

Store state information.

run_id: str#
tb: str#
timeout: int = 5#
unlock(key=None)[source]#

Release any locks on the state.