Skip to main content
Version: Next

AsyncQueue Processor

Overview

The AsyncQueue processor is designed to handle asynchronous requests by placing them in a managed queue for later processing. This is particularly useful for use cases that require deferred handling or prioritization of requests based on custom logic.

This processor ensures efficient throughput and prioritization by enabling users to configure quota usage and optional priority-based handling.

AsyncQueue


Input and Output

This processor operates on the request stream:

  • Input Stream: Request – The processor intercepts incoming requests and queues them for asynchronous processing.

  • Output Stream: Request – After queuing, the request continues through the request stream toward further processing or downstream systems.


Parameters

Each parameter is defined as a key-value pair inside the parameters section.

quota_id

Required: True
Type: string
Identifies the quota resource associated with the request. This ensures requests are tracked and enforced according to the defined quota.

Example:

- key: quota_id
value: "standard-api-usage"

priority_group_by_header

Required: False
Type: string
Specifies the name of a request header used to extract the priority group for the incoming request.

Example:

- key: priority_group_by_header
value: "x-priority-group"

priority_groups

Required: False
Type: map_of_strings
Defines a mapping of priority group names to specific configurations or labels. Used in conjunction with priority_group_by_header to apply priority logic to incoming requests.

Example:

- key: priority_groups
value:
production: 1
staging: 2

Best Practices

  • Ensure the quota_id accurately maps to a defined and enforced quota.
  • Use priority_group_by_header and priority_groups to handle request surges gracefully and ensure important traffic gets prioritized.
  • Combine with async job processors downstream to consume and handle queued requests efficiently.

For more details on configuring flows, visit the Lunar.dev Flows Documentation.


AsyncQueue Processor Template

AsyncQueue Processor
QueueIncomingRequests:
processor: AsyncQueue
parameters:
- key: quota_id
value: "standard-api-usage"
- key: priority_group_by_header
value: "x-priority-group"
- key: priority_groups
value:
"gold": "high"
"silver": "medium"
"bronze": "low"

Use Case

You can use the AsyncQueue processor to manage traffic to a backend service that cannot handle large bursts of traffic in real time. By prioritizing requests from premium customers using x-priority-group headers, you can defer less critical traffic and ensure faster response times for top-tier users.