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
| Parameter | Description | Type | Mandatory / Optional | Example | 
|---|---|---|---|---|
| name | The name of the flow | String | Mandatory | RateQueueManager | 
| filters | Criteria to filter incoming requests | Object | Mandatory | - | 
| url | Define the URL pattern for the filter | String | Mandatory | api.example.com/* | 
| method | List of HTTP methods applicable to the filter | Array of Strings | Optional | [GET, POST] | 
| headers | List of headers to filter incoming requests | Array of Objects | Optional | - | 
| key | The key of the header | String | Mandatory | X-API-Key | 
| value | accepted value for the header | String | Optional | '67890' | 
| processors | List of processors to handle the request | Object | Mandatory | - | 
| Queue | Queue processor for managing request flow | Object | Mandatory | - | 
| processor | Type of processor | String | Mandatory | Queue | 
| parameters | Parameters for the Queue processor | Array of Objects | Mandatory | - | 
| quota_id | Specify the quota ID for the Queue processor | String | Mandatory | MyQueue | 
| ttl_seconds | Time to live for requests in the queue | Integer | Mandatory | 300(5 minutes) | 
| queue_size | Maximum number of requests allowed in the queue | Integer | Mandatory | 100 | 
| priority_group_by_header | Header to determine request priority | String | Optional | X-Priority | 
| priority_groups | Mapping of priority groups with their respective priorities | Map of Objects | Optional | { "premium": 1, "basic": 2 } | 
| GenerateResponse | Processor to generate a response when the queue limit is reached | Object | Mandatory | - | 
| processor | Type of processor | String | Mandatory | GenerateResponse | 
| parameters | Parameters for the GenerateResponse processor | Array of Objects | Mandatory | - | 
| status | HTTP status code for queue limit reached | Integer | Mandatory | 429 | 
| body | Response body text when the limit is exceeded | String | Mandatory | "Queue Limit Exceeded. Please try again later." | 
| Content-Type | Content type for the response | String | Mandatory | text/plain | 
| flow | Definition of the request and response flow | Object | Mandatory | - | 
| request | Configuration for handling incoming requests | Object | Mandatory | - | 
| from | Source of the request flow | Object | Mandatory | - | 
| stream | Name of the stream for processing requests | Object | Mandatory | globalStream | 
| at | Start point for the request flow | String | Mandatory | start | 
| to | Destination for the flow | Object | Mandatory | - | 
| condition | Condition for processing | String | Mandatory | blockedorallowed | 
| response | Configuration for handling responses | Object | Mandatory | - | 
| end | End of the response flow | String | Mandatory | end | 
Quota Configuration
Please refer to the Configure your API Quotas Page.