Download the PHP package thesis/grpc-retry without Composer

On this page you can find all versions of the php package thesis/grpc-retry. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package grpc-retry

thesis/grpc-retry

Retry middleware for thesis/grpc-client: unary and streaming interceptors that transparently re-issue a failed call while its gRPC status is retryable and the attempt budget is not exhausted, pausing between attempts according to a configurable backoff.

Contents

Installation

Usage

Retry\Interceptor implements both client interceptor contracts, so a single instance can be registered on both chains: the unary chain retries request → response calls, the stream chain retries streams. Register it on whichever chains you need.

Configuration

Retry\Config is an immutable dto:

Option Default Meaning
maxAttempts 3 Total number of attempts. 3 means the initial call plus two retries.
retryableCodes [Code::UNAVAILABLE] A retry happens only when the failure carries one of these statuses.
backoff Backoff\Exponential How long to wait before each retry.
maxBufferedMessages 256 How many client messages a stream may buffer for a possible replay.

Transport-level failures (a refused or dropped connection) are surfaced by the client as InvokeError with Code::UNAVAILABLE, so the default policy already covers them. Add more codes (e.g. Code::RESOURCE_EXHAUSTED, Code::DEADLINE_EXCEEDED) only for calls where retrying them is safe.

Backoff

Backoff decides how long to pause before the n-th retry:

Backoff\Exponential

Exponentially growing delay, capped at max, with random jitter to avoid a thundering herd of clients retrying in lockstep:

Jitter is drawn from an injectable Random\Randomizer, so tests can pass a seeded engine for a deterministic delay:

Backoff\Fixed

The same delay before every retry:

Custom

Implement Backoff for any other schedule (decorrelated jitter, a fixed table, no delay at all).

How it works

Both interceptors are endpoint-agnostic: failover is handled by the transport. Every re-issue reuses the call's PickContext, so the load balancer skips the endpoint that just failed whenever it has an alternative. Waits between attempts honour the call's Cancellation: a cancelled call or an expired deadline aborts the wait instead of sleeping it out.

Streaming caveats

A stream can only be retried while no server message has been observed yet. As soon as receive() or iteration yields a value, the call is committed: any later failure is surfaced to the caller unchanged, because replaying it could duplicate already-processed responses. Until then, every sent message is buffered in memory so it can be replayed. That buffer is bounded by maxBufferedMessages: a client- or bidirectional stream that sends more than that before the first response simply stops being retryable (a partial replay would be wrong) and releases the buffer, so memory stays bounded.

Because retries replay the request, only enable them for calls that are safe to execute more than once. Retrying is inherently safe for reads; for writes it requires idempotency (e.g. an idempotency key or a conditional update).

Relation to gRFC A6

The buffer/replay/commit model follows gRFC A6 "client retries": outgoing messages are buffered so a fresh attempt can replay them, and the call commits — retries stop and the buffer is freed — once it can no longer be safely replayed. The backoff formula (min(base * factor^(n-1), max) * random(0.8, 1.2)) and the retryableStatusCodes check come from A6 as well.

It is a deliberate subset, adapted to what a client interceptor can observe:


All versions of grpc-retry with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
amphp/amp Version ^3.1
thesis/googleapis-rpc-types Version ^0.2
thesis/grpc-client Version ^0.2
thesis/grpc-protocol Version ^0.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package thesis/grpc-retry contains the following files

Loading the files please wait ...