pynenc_redis.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_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.

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

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

Initialization

property prefix: str

Read-only property for the Redis key prefix.

invocation(invocation_id: str) str[source]
task(task_id: str) str[source]
args(task_id: str, arg: str, val: str) str[source]
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_status(invocation_id: str) str[source]
pending_timer(invocation_id: str) str[source]
previous_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]
invocation_to_call(invocation_id: str) str[source]

Get the Redis key for mapping an invocation_id to its call_id.

edge(call_id: str) str[source]
reverse_edge(callee_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]
runner_heartbeat(runner_id: str) str[source]
runner_heartbeats() str[source]
history(invocation_id: str) str[source]
history_by_timestamp() str[source]

Get key for sorted set of all history entries indexed by timestamp.

result(invocation_id: str) str[source]
exception(invocation_id: str) str[source]
invocation_auto_purge() str[source]
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.

default_queue() str[source]
client_data_store(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_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_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

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

workflow_type_invocations(workflow_type_key: str) str[source]

Get key for storing invocation IDs grouped by workflow type.

Parameters:

workflow_type_key – The workflow type key (task_id key)

Returns:

Redis key for workflow type 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