pynenc_redis.util.redis_keys¶
Module Contents¶
Classes¶
Helper class to manage Redis key formats for various components. |
Functions¶
Sanitizes a string for use as a Redis key. |
Data¶
API¶
- pynenc_redis.util.redis_keys.PYNENC_KEY_PREFIX¶
‘pynenc’
- pynenc_redis.util.redis_keys.sanitize_for_redis(s: str) str[source]¶
Sanitizes a string for use as a Redis key.
- Parameters:
s (str) – The string to sanitize.
- Returns:
The sanitized string.
- class pynenc_redis.util.redis_keys.Key(app_id: str, prefix: str)[source]¶
Helper class to manage Redis key formats for various components.
Initialization
- status_to_invocations(status: pynenc.invocation.status.InvocationStatus) str[source]¶
Get the Redis key for the set of invocation IDs with a specific status.
- invocation_to_call(invocation_id: str) str[source]¶
Get the Redis key for mapping an invocation_id to its call_id.
- history_by_timestamp() str[source]¶
Get key for sorted set of all history entries indexed by timestamp.
- all_invocations_by_time() str[source]¶
Get key for sorted set of all invocation IDs indexed by registration time.
- task_invocations_by_time(task_id: str) str[source]¶
Get key for sorted set of invocation IDs for a task indexed by registration time.
- purge(client: redis.Redis) None[source]¶
Purges all keys with the given prefix in Redis.
- Parameters:
client (redis.Redis) – The Redis client.
- condition_triggers(condition_id: str) str[source]¶
Get key for storing triggers that use a condition.
- cron_last_execution(condition_id: str) str[source]¶
Generate a key for storing the last execution time of a cron condition.
- Parameters:
condition_id – ID of the cron condition
- Returns:
Redis key string
- source_task_conditions(task_id: str) str[source]¶
Generate key for source task to condition mapping.
This key stores conditions that are sourced from a specific task.
- Parameters:
task_id – ID of the source task
- Returns:
Redis key for task’s source conditions
- trigger_execution_claim(trigger_id: str, valid_condition_id: str) str[source]¶
Generate a key for a trigger execution claim.
This key is used to atomically claim the right to execute a trigger for a specific valid condition across multiple workers.
- Parameters:
trigger_id – ID of the trigger definition
valid_condition_id – ID of the valid condition
- Returns:
Redis key for the trigger execution claim
- trigger_run_claim(trigger_run_id: str) str[source]¶
Generate a key for a trigger run claim.
This key is used to atomically claim the right to execute a specific trigger run across multiple workers. A trigger run is a unique execution attempt for a trigger and its satisfied conditions.
- Parameters:
trigger_run_id – Unique ID for this trigger run
- Returns:
Redis key for the trigger run claim
- workflow_run_by_id(workflow_id: str) str[source]¶
Get key for storing a workflow run by its unique workflow_id.
- Parameters:
workflow_id – The unique workflow ID
- Returns:
Redis key for the workflow run
- workflow_type_index(workflow_type: str) str[source]¶
Get key for storing the set of workflow_ids for a workflow_type.
- Parameters:
workflow_type – The workflow type (task_id)
- Returns:
Redis key for the workflow type index set
- workflow_types() str[source]¶
Get key for storing workflow types set.
This key automatizes purge as it follows the app-scoped prefix pattern.
- Returns:
Redis key for workflow types set
- workflow_deterministic_value(workflow_id: str, key: str) str[source]¶
Get key for storing a deterministic value for workflow operations.
- Parameters:
workflow_id – ID of the workflow
key – Identifier for the deterministic value
- Returns:
Redis key for the deterministic value
- runner_context(runner_id: str) str[source]¶
Get key for storing a runner context.
- Parameters:
runner_id – The runner’s unique identifier
- Returns:
Redis key for the runner context
- workflow_sub_invocations(workflow_id: str) str[source]¶
Get key for storing sub-invocation IDs that run inside a workflow.
This key automatizes purge as it follows the app-scoped prefix pattern.
- Parameters:
workflow_id – ID of the workflow
- Returns:
Redis key for workflow sub-invocations set
- parent_invocation_children(parent_invocation_id: str) str[source]¶
Get key for storing child invocation IDs spawned by a parent invocation.
- Parameters:
parent_invocation_id – The parent invocation ID
- Returns:
Redis key for parent’s child invocations set
- workflow_invocations(workflow_id: str) str[source]¶
Get key for storing invocation IDs that belong to a specific workflow.
- Parameters:
workflow_id – ID of the workflow
- Returns:
Redis key for workflow invocations set