pynenc.util.redis_keys

Module Contents

Classes

Key

Helper class to manage Redis key formats for various components.

Functions

sanitize_for_redis

Sanitizes a string for use as a Redis key.

Data

API

pynenc.util.redis_keys.PYNENC_KEY_PREFIX

pynenc

pynenc.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.util.redis_keys.Key(app_id: str, prefix: str)[source]

Helper class to manage Redis key formats for various components.

Parameters:
  • app_id (str) – The application ID.

  • prefix (str) – The prefix for the keys.

Initialization

invocation(invocation_id: str) str[source]
task(task_id: str) str[source]
args(task_id: str, arg: str, val: str) str[source]
status(task_id: str, status: pynenc.invocation.status.InvocationStatus) str[source]
pending_timer(invocation_id: str) str[source]
previous_status(invocation_id: str) str[source]
invocation_status(invocation_id: str) str[source]
invocation_retries(invocation_id: str) str[source]
call(call_id: str) str[source]
call_to_invocation(call_id: str) str[source]
edge(call_id: str) str[source]
waiting_for(invocation_id: str) str[source]
waited_by(invocation_id: str) str[source]
all_waited() str[source]
not_waiting() str[source]
history(invocation_id: str) str[source]
result(invocation_id: str) str[source]
exception(invocation_id: str) str[source]
invocation_auto_purge() str[source]
default_queue() str[source]
arg_cache(key: str) str[source]
purge(client: redis.Redis) None[source]

Purges all keys with the given prefix in Redis.

Parameters:

client (redis.Redis) – The Redis client.

condition(condition_id: str) str[source]

Get key for storing a trigger condition.

trigger(trigger_id: str) str[source]

Get key for storing a trigger definition.

valid_condition(condition_id: str) str[source]

Get key for storing a valid condition.

task_triggers(task_id: str) str[source]

Get key for storing triggers associated with a task.

condition_triggers(condition_id: str) str[source]

Get key for storing triggers that use a condition.

event_channel() str[source]

Get channel name for publishing trigger events.

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_data_value(workflow_id: str, key: str) str[source]
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

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_runs(workflow_task_id: str) str[source]

Get key for storing workflow runs list for a specific workflow type.

This key automatizes purge as it follows the app-scoped prefix pattern.

Parameters:

workflow_task_id – ID of the workflow task type

Returns:

Redis key for workflow runs list

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

static all_apps_info_key(app_id: str) str[source]

Get key for storing app information in the central registry.

This uses a special prefix outside the normal app namespace to make discovery possible across all apps.

Parameters:

app_id – The ID of the app

Returns:

Redis key for app information