Skip to main content

@upyo/retry@0.6.1
Built and signed on GitHub Actions

Works with
This package works with Cloudflare Workers, Node.js, Deno, Bun
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
•JSR Score100%•
License
MIT
•
Downloads14/wk
•
Published2 days ago (0.6.1)

Retry and backoff decorator transport for Upyo email library

Classes

c
RetryTransport<TProviderId extends string = string>(
transport: Transport<TProviderId>,
config?: RetryConfig<TProviderId>
)

Transport decorator that retries transient delivery failures.

  • config: ResolvedRetryConfig<TProviderId>

    Resolved retry configuration.

  • id: TProviderId
    No documentation available
  • send(
    message: Message,
    options?: TransportOptions
    ): Promise<Receipt<TProviderId>>

    Sends one message, retrying retryable failures.

  • sendMany(
    messages: Iterable<Message> | AsyncIterable<Message>,
    options?: TransportOptions
    ): AsyncIterable<Receipt<TProviderId>>

    Sends messages with per-message retry behavior.

Functions

f
createRetryTransport<TProviderId extends string = string>(
baseTransport: Transport<TProviderId>,
config?: RetryConfig<TProviderId>
): RetryTransport<TProviderId>

Creates a retrying transport around another transport.

Interfaces

I

Exponential backoff settings for retry delays.

I

Context passed to custom retry wait functions.

  • attempt: number

    Attempt that just failed.

  • Delay to wait before retrying, in milliseconds.

  • error: unknown

    Thrown error that caused the retry, when the transport rejected.

  • maxAttempts: number

    Maximum configured attempts.

  • nextAttempt: number

    Attempt that will run after this delay.

  • reason: "retry" | "sendMany-throttle"

    Why the delay is being applied.

  • receipt: Receipt<TProviderId> & { readonly successful: false; }

    Failed receipt that caused the retry, when the transport returned one.

I

Configuration for the retry transport decorator.

  • backoff: BackoffConfig

    Exponential backoff settings.

  • jitter: JitterConfig

    Jitter mode applied to computed backoff delays.

  • maxAttempts: number

    Total number of send attempts, including the first one.

  • random: () => number

    Random number source for jitter.

  • sendMany: SendManyRetryConfig

    Retry and throttling behavior for sendMany().

  • shouldRetry: RetryClassifier<TProviderId>

    Custom retry classifier.

  • wait: WaitFunction<TProviderId>

    Custom wait function for tests or host-controlled scheduling.

I

Retry behavior for sendMany().

  • Minimum delay between launching message sends, in milliseconds.

  • Maximum number of messages to send at the same time.

Type Aliases

T
JitterConfig = false | "none" | "full"

Jitter mode for computed retry delays.

T
RetryClassifier<TProviderId extends string = string> = (failure: RetryFailure<TProviderId>) => boolean

Function that decides whether a failure should be retried.

T
RetryFailure<TProviderId extends string = string> =
{ readonly kind: "receipt"; readonly receipt: Receipt<TProviderId> & { readonly successful: false; }; }
| { readonly kind: "error"; readonly error: unknown; readonly receiptError?: ReceiptError<TProviderId>; }

Failure passed to a custom retry classifier.

T
WaitFunction<TProviderId extends string = string> = (
context: DelayContext<TProviderId>,
signal?: AbortSignal
) => Promise<void>

Function used to wait between attempts or throttled sends.

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@upyo/retry

Import symbol

import * as mod from "@upyo/retry";
or

Import directly with a jsr specifier

import * as mod from "jsr:@upyo/retry@^0.6.1";
⌂