Handling errors and retrying
Event reliability in DevRev snap-ins
The DevRev snap-ins platform offers event reliability features to ensure smooth and resilient event processing. This document provides an overview of these features and how developers can leverage them to build reliable snap-ins.
Getting started
To start using the event reliability features in your Snap-ins, follow these steps:
- Update your DevRev SDK to the latest version.
- Define retryable errors using the
FunctionExecutionError
interface in your Snap-in code. - Configure the retry behavior in your snap-in manifest.
- Handle errors appropriately in your snap-in function.
Retryable errors
Snap-ins can define retryable errors using the FunctionExecutionError
interface provided by the DevRev SDK. This enables the platform to automatically retry events that encounter intermittent or transient errors, improving overall reliability.
Retry configuration
Developers can configure the retry behavior of their snap-in functions using the snap-in manifest. The following options are available:
max_retries
: The maximum number of retries before marking the event as failed.min_interval
: The minimum interval in seconds between each retry attempt. This interval may be adjusted based on the timeout of the corresponding function.
Error handling
The DevRev snap-in platform handles errors based on the ordering guarantees of the snap-in function.
For snap-in functions with relaxed ordering, non-retryable errors are marked as failed, and the errored event is propagated to the DevRev platform for tracking. Retryable errors are automatically retried based on the specified retry configuration. If the maximum number of retries is exhausted, the errored events are moved to a dead-letter queue (DLQ) for further handling.
Error interface
The DevRev SDK defines the FunctionExecutionError
type to represent errors returned from the snap-in’s run function. Developers can use this type to provide additional error details and indicate whether an error is retryable.
Example usage
Here’s an example of how to use the FunctionExecutionError
in your Snap-in code:
In this example, the Snap-in function’s run
method processes the events and can throw a FunctionExecutionError
to indicate whether the error is retryable or not. The Snap-in platform handles the error based on the retry
and refresh
properties set in the error object.