OperationRetry
Namespace: Vercel.AI.Operations
public static class OperationRetryRetries a provider call the way prepareRetries does.
Inheritance: object
Methods
Section titled “Methods”ExecuteAsync<T>(int?, CancellationToken, Exception?, Func<CancellationToken, Task<T>>, Func<Exception, bool>?)
Section titled “ExecuteAsync<T>(int?, CancellationToken, Exception?, Func<CancellationToken, Task<T>>, Func<Exception, bool>?)”public static Task<T> ExecuteAsync<T>(int? maxRetries, CancellationToken cancellationToken, Exception? abortReason, Func<CancellationToken, Task<T>> action, Func<Exception, bool>? additionalRetryable)Validates <code class=“paramref”>maxRetries</code> and runs <code class=“paramref”>action</code>.
Type parameters
| Name | Description |
|---|---|
T |
Parameters
| Name | Type | Description |
|---|---|---|
maxRetries |
int? | |
cancellationToken |
CancellationToken | |
abortReason |
Exception | |
action |
Func<CancellationToken, Task<T>> | |
additionalRetryable |
Func<Exception, bool> |
Returns: Task<T>
ResolveMaxRetries(int?, string)
Section titled “ResolveMaxRetries(int?, string)”public static int ResolveMaxRetries(int? maxRetries, string parameter = "maxRetries")Returns the retry count after validation. Null becomes 2.
Parameters
| Name | Type | Description |
|---|---|---|
maxRetries |
int? | |
parameter |
string |
Returns: int
ThrowIfAborted(CancellationToken, Exception?)
Section titled “ThrowIfAborted(CancellationToken, Exception?)”public static void ThrowIfAborted(CancellationToken cancellationToken, Exception? reason)Throws <code class=“paramref”>reason</code> when the token is cancelled.
Parameters
| Name | Type | Description |
|---|---|---|
cancellationToken |
CancellationToken | |
reason |
Exception |
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product