Skip to main content
Version: 1.0.x

Flow Configuration Template

Flow Configuration

/etc/lunar-proxy/flows/flow.yaml
name: PriorityQueueFlow # The name of the flow

filter:
url: <URLPattern> # Define the URL pattern for the filter, e.g., api.example.com/*
method:
- <HTTPMethod> # Optional: List of HTTP methods, e.g., GET, POST
headers:
- key: <HeaderKey> # Optional: Header key, e.g., 'X-API-Key'
value: <HeaderValue> # Optional: header value, e.g., '12345', '67890'

processors:
Queue:
processor: Queue # Queue processor for managing request flow
parameters:
- key: quota_id
value: <QuotaID> # Specify the quota ID, e.g., MyQueue
- key: ttl_seconds
value: <TTLInSeconds> # Time to live for requests in the queue
- key: queue_size
value: <MaxQueueSize> # Maximum number of requests in the queue
- key: priority_group_by_header
value: <HeaderForPriorityGroup> # Optional: Header to determine request priority
- key: priority_groups
value:
<Group1>: <Priority1> # Optional: Priority groups with their respective priorities
<Group2>: <Priority2>

GenerateResponse:
processor: GenerateResponse # Generate a response when the queue limit is reached
parameters:
- key: status
value: 429 # HTTP status code for queue limit reached, e.g., 429 (Too Many Requests)
- key: body
value: "Queue Limit Exceeded. Please try again later." # Response body text
- key: Content-Type
value: text/plain # Content type for the response

flow:
request:
- from:
stream:
name: globalStream # The stream to start the request flow
at: start # Start point
to:
processor:
name: Queue # Process the request through the Queue processor

- from:
processor:
name: Queue # After the Queue processor
condition: blocked # If the request is blocked due to queue limit reached
to:
processor:
name: GenerateResponse # Generate the 429 response

- from:
processor:
name: Queue # After the Queue processor
condition: allowed # If the request is allowed (below queue limit)
to:
stream:
name: globalStream # Send the request to the global stream
at: end # End point of the request flow

response:
- from:
processor:
name: GenerateResponse # In case of queue limit reached, send the response
to:
stream:
name: globalStream # Send response back to the global stream
at: end # End point of the response flow

ParameterDescriptionTypeMandatory / OptionalExample
nameThe name of the flowStringMandatoryRateQueueManager
filtersCriteria to filter incoming requestsObjectMandatory-
urlDefine the URL pattern for the filterStringMandatoryapi.example.com/*
methodList of HTTP methods applicable to the filterArray of StringsOptional[GET, POST]
headersList of headers to filter incoming requestsArray of ObjectsOptional-
keyThe key of the headerStringMandatoryX-API-Key
valueaccepted value for the headerStringOptional'67890'
processorsList of processors to handle the requestObjectMandatory-
QueueQueue processor for managing request flowObjectMandatory-
processorType of processorStringMandatoryQueue
parametersParameters for the Queue processorArray of ObjectsMandatory-
quota_idSpecify the quota ID for the Queue processorStringMandatoryMyQueue
ttl_secondsTime to live for requests in the queueIntegerMandatory300 (5 minutes)
queue_sizeMaximum number of requests allowed in the queueIntegerMandatory100
priority_group_by_headerHeader to determine request priorityStringOptionalX-Priority
priority_groupsMapping of priority groups with their respective prioritiesMap of ObjectsOptional{ "premium": 1, "basic": 2 }
GenerateResponseProcessor to generate a response when the queue limit is reachedObjectMandatory-
processorType of processorStringMandatoryGenerateResponse
parametersParameters for the GenerateResponse processorArray of ObjectsMandatory-
statusHTTP status code for queue limit reachedIntegerMandatory429
bodyResponse body text when the limit is exceededStringMandatory"Queue Limit Exceeded. Please try again later."
Content-TypeContent type for the responseStringMandatorytext/plain
flowDefinition of the request and response flowObjectMandatory-
requestConfiguration for handling incoming requestsObjectMandatory-
fromSource of the request flowObjectMandatory-
streamName of the stream for processing requestsObjectMandatoryglobalStream
atStart point for the request flowStringMandatorystart
toDestination for the flowObjectMandatory-
conditionCondition for processingStringMandatoryblocked or allowed
responseConfiguration for handling responsesObjectMandatory-
endEnd of the response flowStringMandatoryend

Quota Configuration

Please refer to the Configure your API Quotas Page.