Global Keys
Global keys are unique identifiers (strings) that enable you to track and correlate tasks across different queues in your organization. They serve as a powerful mechanism to establish relationships between tasks and maintain context throughout your workflow.
While you can use any separator in your global keys, we strongly recommend
using - for consistency and readability (e.g., order-123, customer-456).
Use Cases
Context-Aware Task Processing
When processing a refund request task with the global key user-123, you can easily retrieve all related tasks across different queues like user_complaints or user_support using global_keys__contains. This consolidated view helps in making informed decisions about refund approvals.
A/B Testing
Global keys facilitate version comparison by tagging tasks with identifiers like ai-release_candidate-1 and ai-release_candidate-2. This enables systematic comparison of task outcomes to evaluate different versions of your system.
Resource Usage Analytics
Track resource utilization patterns by using global keys like user-123. Using global_keys__count, you can analyze task distribution across users and identify high-resource consumers, helping optimize resource allocation.
Usage
When creating a task, you can associate it with up to 10 global keys:
{
"input_data": { ... },
"global_keys": ["order-123", "customer-456"]
}Characteristics
- Global keys are user-defined string identifiers
- Each task can be associated with up to 10 global keys
- They are optional but essential for establishing relationships between tasks in complex workflows
- Global keys are immutable after task creation
Query Support
Count-based Queries
You can filter tasks based on their global key count:
- Exact count:
global_keys__count - Minimum count:
global_keys__count__gte - Maximum count:
global_keys__count__lte
Content-based Queries
Filter tasks based on specific global keys:
- Include key:
global_keys__contains - Exclude key:
global_keys__not__contains
Best Practices
- Implement consistent naming conventions for global keys
- Create concise yet descriptive key names
- Use meaningful prefixes to categorize keys (e.g.,
order-,customer-) - Leverage global keys for cross-queue task correlation
- Maintain documentation of your global key schema
- Structure hierarchical relationships in keys (e.g.,
store-123-order-456) - Group related tasks using common key prefixes (e.g.,
order-123-item-1,order-123-item-2)