DataBridge Documentation 2.0.17
A Java library for managing database connections and transactions
Loading...
Searching...
No Matches
io.github.kdesp73.databridge.helpers.Again Class Reference

Classes

interface  RetryableTask
 

Static Public Member Functions

static long delay ()
 
static int retries ()
 
static< T > T retryWithDelay (RetryableTask< T > task, int maxRetries, long delay) throws SQLException
 
static< T > T retryWithExponentialBackoff (RetryableTask< T > task, int maxRetries, long initialDelay) throws SQLException
 

Detailed Description

The Again class provides utility methods for retrying tasks with specified retry mechanisms, including simple retries with delays and retries with exponential backoff.

It retrieves configuration values such as retry times, retry delay, and retry activation from the Config instance. If retrying is not enabled in the configuration, tasks are executed without retries.

The class supports retrying tasks up to a maximum number of attempts with a specified delay between each attempt. It also supports exponential backoff, where the delay increases after each failure.

Author
KDesp73

Member Function Documentation

◆ delay()

static long io.github.kdesp73.databridge.helpers.Again.delay ( )
static

Gets the delay between retries from the configuration or uses the default value.

Returns
The delay between retries in milliseconds.

◆ retries()

static int io.github.kdesp73.databridge.helpers.Again.retries ( )
static

Gets the maximum number of retry attempts from the configuration or uses the default value.

Returns
The maximum number of retry attempts.

◆ retryWithDelay()

static< T > T io.github.kdesp73.databridge.helpers.Again.retryWithDelay ( RetryableTask< T > task,
int maxRetries,
long delay ) throws SQLException
static

Retries a task a specified number of times with a fixed delay between retries.

If retries are not enabled in the configuration, the task is executed without retries.

Parameters
taskThe task to retry.
maxRetriesThe maximum number of retry attempts.
delayThe delay between retry attempts in milliseconds.
<T>The return type of the task.
Returns
The result of the task, or null if the task failed after the maximum retries.
Exceptions
SQLExceptionIf an error occurs during task execution.

◆ retryWithExponentialBackoff()

static< T > T io.github.kdesp73.databridge.helpers.Again.retryWithExponentialBackoff ( RetryableTask< T > task,
int maxRetries,
long initialDelay ) throws SQLException
static

Retries a task a specified number of times with exponential backoff between retries.

Exponential backoff doubles the delay between each retry attempt.

If retries are not enabled in the configuration, the task is executed without retries.

Parameters
taskThe task to retry.
maxRetriesThe maximum number of retry attempts.
initialDelayThe initial delay between retries in milliseconds.
<T>The return type of the task.
Returns
The result of the task, or null if the task failed after the maximum retries.
Exceptions
SQLExceptionIf an error occurs during task execution.

The documentation for this class was generated from the following file: