Skip to main content
Version: Next

Flow Example

This is an example of a fully configured Retry Flow that retries failed API requests based on status codes, with exponential backoff.

/etc/lunar-proxy/flows/flow.yaml
name: RetryFlow

filter:
url: "api.com/resource/{id}"

processors:
RetryProcessor:
processor: Retry
parameters:
- key: attempts
value: 5
- key: cooldown_between_attempts_seconds
value: 5
- key: cooldown_multiplier
value: 1.5
metrics:
enabled: true
labels:
- flow_name
- processor_key
- http_method
- host
- status_code
- consumer_tag


FilterProcessor:
processor: Filter
parameters:
- key: status_code_range
value: 400-500
metrics:
enabled: true
labels:
- flow_name
- processor_key
- http_method
- host
- status_code
- consumer_tag

flow:
request:
- from:
stream:
name: globalStream
at: start
to:
stream:
name: globalStream
at: end

response:
- from:
stream:
name: globalStream
at: start
to:
processor:
name: FilterProcessor
- from:
processor:
name: FilterProcessor
condition: miss
to:
stream:
name: globalStream
at: end

- from:
processor:
name: FilterProcessor
condition: hit
to:
processor:
name: 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

Troubleshooting

  1. Retries Not Triggering:
    • Verify that status_code_range is correctly configured.
    • Ensure the API response status code falls within the specified range.
  2. Excessive Retry Attempts:
    • Check the attempts parameter and reduce it if necessary.
    • Adjust the cooldown_multiplier to increase wait times between retries.
    • Make sure that in case of long cooldown the value of LUNAR_RETRY_REQUEST_TIMEOUT_SEC is also increased. the default is 100