UTIL_Retry.Context
Class
global interface UTIL_Retry.ContextInterface defining the retry context. Contains information about the current retry attempt including count, timing, and custom data.
Since: 1.0
Methods
| Method | Description |
|---|---|
| global abstract Integer getBaseBackoff() | Gets the configured base backoff in seconds |
| global abstract Object getCustomData() | Gets custom data for use with custom retry strategies |
| global abstract Datetime getLastAttemptTime() | Gets the datetime of the last retry attempt |
| global abstract Integer getMaxBackoff() | Gets the configured maximum backoff in seconds |
| global abstract Integer getRetryCount() | Gets the current retry attempt number (0 = first attempt, 1 = first retry, etc.) |
| global abstract UTIL_Retry.Context withCustomData(Object data) | Sets custom data for use with custom retry strategies (fluent API) |
| global abstract UTIL_Retry.Context withLastAttemptTime(Datetime dt) | Sets the last attempt time (fluent API) |
Method Details
getBaseBackoff
global abstract Integer getBaseBackoff()Gets the configured base backoff in seconds
Returns: Integer - The base backoff period
Example:
UTIL_Retry.Context ctx = UTIL_Retry.newContext(1);
UTIL_Retry.Strategy strategy = UTIL_Retry.linear();
strategy.calculateBackoff(ctx);
Integer baseBackoff = ctx.getBaseBackoff(); // Returns 10 (default)getCustomData
global abstract Object getCustomData()Gets custom data for use with custom retry strategies
Returns: Object - The custom data object, or null if not set
Example:
Map<String, Object> data = new Map<String, Object>{'error' => '429'};
UTIL_Retry.Context ctx = UTIL_Retry.newContext(1)
.withCustomData(data);
Object customData = ctx.getCustomData();getLastAttemptTime
global abstract Datetime getLastAttemptTime()Gets the datetime of the last retry attempt
Returns: Datetime - The last attempt time, or null if not set
Example:
UTIL_Retry.Context ctx = UTIL_Retry.newContext(1)
.withLastAttemptTime(Datetime.now());
Datetime lastAttempt = ctx.getLastAttemptTime();getMaxBackoff
global abstract Integer getMaxBackoff()Gets the configured maximum backoff in seconds
Returns: Integer - The maximum backoff period
Example:
UTIL_Retry.Context ctx = UTIL_Retry.newContext(1);
UTIL_Retry.Strategy strategy = UTIL_Retry.exponential();
strategy.calculateBackoff(ctx);
Integer maxBackoff = ctx.getMaxBackoff(); // Returns 300 (default)getRetryCount
global abstract Integer getRetryCount()Gets the current retry attempt number (0 = first attempt, 1 = first retry, etc.)
Returns: Integer - The retry count
Example:
UTIL_Retry.Context ctx = UTIL_Retry.newContext(2);
Integer count = context.getRetryCount(); // Returns 2withCustomData
global abstract UTIL_Retry.Context withCustomData(Object data)Sets custom data for use with custom retry strategies (fluent API)
Parameters:
data(Object) - The custom data (SObject, Map, List, custom class, etc.)
Returns: UTIL_Retry.Context - This context for method chaining
Example:
ApiCall__c apiCall = [SELECT Id, StatusCode__c FROM ApiCall__c LIMIT 1];
UTIL_Retry.Context ctx = UTIL_Retry.newContext(1)
.withCustomData(apiCall);withLastAttemptTime
global abstract UTIL_Retry.Context withLastAttemptTime(Datetime dt)Sets the last attempt time (fluent API)
Parameters:
dt(Datetime) - The datetime of the last attempt
Returns: UTIL_Retry.Context - This context for method chaining
Example:
UTIL_Retry.Context ctx = UTIL_Retry.newContext(1)
.withLastAttemptTime(Datetime.now());