Flow Configuration Template
Flow Configuration
/etc/lunar-proxy/flows/flow.yaml
name: <FlowName> # The name of the flow, e.g., ClientSideLimitingFlow
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:
Limiter:
processor: Limiter # Limiter processor for rate limiting
parameters:
- key: quota_id
value: <QuotaID> # Specify the quota ID, e.g., MyQuota
GenerateResponse:
processor: GenerateResponse # Generate a response when a limit is exceeded
parameters:
- key: status
value: 429 # HTTP status code for quota exceeded, e.g., 429 (Too Many Requests)
- key: body
value: "Quota 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: Limiter # Process the request through the Limiter processor
- from:
processor:
name: Limiter # After the Limiter processor
condition: above_limit # If the request is blocked due to quota exceeded
to:
processor:
name: GenerateResponse # Generate the 429 response
- from:
processor:
name: Limiter # After the Limiter processor
condition: below_limit # If the request is allowed (below quota 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 quota exceeded, send the response
to:
stream:
name: globalStream # Send response back to the global stream
at: end # End point of the response flow
Parameter | Description | Type | Mandatory/Optional | Example |
---|---|---|---|---|
name | The name of the flow, describing its purpose or function. | String | Mandatory | ClientSideLimitingFlow |
filter.url | URL pattern to match requests for this flow. | String | Mandatory | api.website.com/* |
filter.method | List of HTTP methods (GET, POST, etc.) that the flow applies to. | List | Optional | ['GET', 'POST'] |
filter.headers.key | Header key for filtering requests. Used to apply limits based on specific headers. | String | Optional | X-API-Key |
filter.headers.value | header value to match the header key. | List | Optional | '67890' |
processors.Limiter.processor | The processor that handles rate-limiting. | String | Mandatory | Limiter |
processors.Limiter.parameters.key | Key to specify the parameter for the limiter processor. | String | Mandatory | quota_id |
processors.Limiter.parameters.value | Value of the quota used by the limiter. | String | Mandatory | MyQuota |
processors.GenerateResponse.processor | Processor that generates the response when the limit is exceeded. | String | Mandatory | GenerateResponse |
processors.GenerateResponse.parameters.key | Key to specify the response parameter (e.g., status, body, content type). | String | Mandatory | status, body, Content-Type |
processors.GenerateResponse.parameters.value | Values corresponding to the keys (status code, response message, content type). | Varies | Mandatory | 429, Quota Exceeded..., text/plain |
flow.request.from.stream.name | Name of the stream used at the start of the request flow. | String | Mandatory | globalStream |
flow.request.from.stream.at | The point in the stream where the flow starts. | String | Mandatory | start |
flow.request.to.processor.name | Name of the processor to route the request to. | String | Mandatory | Limiter, GenerateResponse |
flow.request.to.processor.condition | Condition to determine whether the request is blocked or allowed (quota exceeded or not). | String | Optional | above_limit, below_limit |
flow.response.from.processor.name | Name of the processor for generating the response in case of quota exceeded. | String | Mandatory | GenerateResponse |
flow.response.to.stream.name | Name of the stream to send the response to. | String | Mandatory | globalStream |
flow.response.from.stream.at | The point in the stream where the response starts. | String | Mandatory | start |
Quota Configuration
Please refer to the Configure your API Quotas Page.