class MeilisearchRetryPolicy

Retry policy for the Meilisearch HTTP client.

The meilisearch/meilisearch-php client has no built-in retry mechanism (unlike Algolia's PHP client which has host failover, and Typesense's which has num_retries). Hypervel adds HTTP-level retry at the Guzzle handler-stack layer for parity, using this policy to decide which responses or exceptions warrant a retry and how long to wait.

Constants

private RETRYABLE_STATUS_CODES

Status codes that indicate transient failures and should be retried.

Methods

static bool
shouldRetry(ResponseInterface|null $response, Throwable|null $exception)

Determine whether a response or exception should trigger a retry.

static int
nextDelayMs(int $attempt, int $baseDelayMs)

Calculate the delay in milliseconds before the given retry attempt.

static callable
middleware(int $maxRetries, int $baseDelayMs)

Build a Guzzle retry middleware configured with this policy.

Details

at line 32
static bool shouldRetry(ResponseInterface|null $response, Throwable|null $exception)

Determine whether a response or exception should trigger a retry.

Parameters

ResponseInterface|null $response
Throwable|null $exception

Return Value

bool

at line 51
static int nextDelayMs(int $attempt, int $baseDelayMs)

Calculate the delay in milliseconds before the given retry attempt.

Attempts are 1-based: the first retry waits $baseDelayMs, the second waits twice that, and so on (exponential backoff).

Parameters

int $attempt
int $baseDelayMs

Return Value

int

at line 59
static callable middleware(int $maxRetries, int $baseDelayMs)

Build a Guzzle retry middleware configured with this policy.

Parameters

int $maxRetries
int $baseDelayMs

Return Value

callable