Flow Configuration Template
Flow Configuration
/etc/lunar-proxy/flows/flow.yaml
# Name of the flow for identification purposes
name: RetryFlow
# Filter configuration to specify which requests the flow applies to
filter:
  url: "api.com/resource/{id}"  # Target URL pattern for retry logic
# Processor configuration for the Retry Flow
processors:
  FilterProcessor:
    processor: Filter
    parameters:
      - key: status_code_range
        value: 400-500 # Set the range if status code to trigger the filter.
    metrics:
      enabled: true
      labels:
        - flow_name
        - processor_key
        - http_method
        - host
        - status_code
        - consumer_tag
  RetryProcessor:
    processor: Retry  # Specifies the Retry processor
    parameters:
      - key: attempts
        value: 3  # Maximum number of retry attempts
      - key: cooldown_between_attempts_seconds
        value: 2  # Initial cooldown time before the first retry (in seconds)
      - key: cooldown_multiplier
        value: 2  # Multiplier for exponential backoff
    # Metrics configuration for tracking retry behavior
    metrics:
      enabled: true  # Enables metric collection
      labels:
        - flow_name  # Include the flow name as a label
        - processor_key  # Include the processor key as a label
        - http_method  # Include the HTTP method (GET, POST, etc.)
        - url  # Include the URL of the request
        - status_code  # Include the HTTP status code of the response
# Flow definition for request handling
flow:
  request:
    # Start of the request flow
    - from:
        stream:
          name: globalStream  
          at: start
      to:
        stream:
          name: globalStream
          at: end
  response:
    # Start the response flow
    - from:
        stream:
          name: globalStream # Use the global stream for capturing requests
          at: start
      to:
        processor:
          name: FilterProcessor 
    - from: 
        processor:
          name: FilterProcessor
          condition: miss
      to:
        stream:
          name: globalStream
          at: end
    - from:
        processor:
          name: FilterProcessor
          condition: hit # In case the status code match the configured range
      to:
        processor:
          name: RetryProcessor # Route the request to the RetryProcessor
    - from:
        processor:
          name: RetryProcessor
          condition: retry
        
      to:
        stream:
          name: globalStream
          at: end
    - from:
        processor:
          name: RetryProcessor
          condition: failed
      to:
        stream:
          name: globalStream
          at: end
Configuration Fields Explained
| Processor | Field | Description | Example Value | 
|---|---|---|---|
| Filter | status_code_range | Look for a status code in the give range. | 400-500 | 
| Retry | attempts | Maximum number of retry attempts. | 3 | 
| Retry | cooldown_between_attempts_seconds | Initial wait time before the first retry. | 2 | 
| Retry | cooldown_multiplier | Multiplier for exponential backoff. | 2 | 
In case of long cooldown periods please verify that the LUNAR_RETRY_REQUEST_TIMEOUT_SEC environment variable is correctly configured, the default is set to 100