Download the PHP package gohany/rtry without Composer

On this page you can find all versions of the php package gohany/rtry. 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 rtry

Rtry — A pragmatic PHP retry & backoff toolkit

tests codecov

Robust, composable retries for HTTP, RPC, queues, and DB work. Rtry focuses on clear policy specs, safe defaults, and first‑class support for jitter, hedging, deadlines, and rate‑limit headers.

Namespaces used in this repo include Gohany\Rtry (implementation & policy) and Gohany\Retry (interfaces / runtime). The library targets PHP 7.4+ and works on PHP 8.x.


Table of contents

The specification docs are in SPEC.md.


Features


Install

Via Composer:


Quick start


Core concepts

Retry runtime

Gohany\Rtry\Impl\Retry orchestrates attempts:

Retry policy

Implemented by RetryPolicyInterface (base) and enriched by RtryPolicyInterface (jitter/hedge/backoff/classifier). Build via RtryPolicyFactory from an array spec or use the underlying parts (e.g., Attempts, Delay, Sequence, Jitter, Hedge).

Delays & sequences

Use a fixed backoff, exponential, or an explicit sequence.

Jitter

Jitter smooths out stampedes by randomizing delays.

JitterSpecInterface:

Spec examples for 'j':

Hedging

Run multiple lanes concurrently with a stagger delay, cancel others on first success/completion.

HedgeSpecInterface:

Spec examples for 'h':

Deadlines vs per‑attempt timeout

If there’s not enough budget for the next delay, Retry gives up and triggers the onGiveUp hook.

Following rate limit headers

With fh=1 (followHeaders=true), Retry consults the failure classifier to extract hints from responses:

The RateLimitBackoffRule returns FailureMetadata with minNextDelayMs or notBeforeUnixMs, and tags like RATE_LIMITED.

Deciders

Control whether to retry:

Rule‑based failure classification

RuleBasedFailureClassifier applies rules to a Throwable to derive status, tags, context patch, headers, and backoff hints:

Derived tags include ETIMEDOUT, ECONNRESET, NETWORK_ERROR, and DB DEADLOCK heuristics.


Rtry spec: authoring policies concisely

You can configure multiple candidate values per key (the factory will validate & choose). Common keys:

Key Meaning Examples
a attempts 5, [5,10]
sa start after 200, '200ms', '200s', '2m', '1h'
dl deadline budget 200, '200ms', '2s', '1m'
cap cap for attempts '200ms', '2m', '1h'
j jitter '20%@pm', '100ms@pm', '50@full', '1.5m@full'
h hedge '2@100ms', '3@100&1'
seq explicit delay sequence '(50,100ms,1.5s*)', 'seq=(50,100,1.5s,*)', '50,100,1.5s*' (canonical prints as seq=…)
fh follow headers (bool) true / false
b exponential base 2, 2.5
on on tags 5xx, 429, ratelimit, throttle, 4xx

Tip: numbers without unit default to milliseconds. 1.5m and 1.5s are supported; decimals for h/m/s are allowed.


Hooks


Duration tokens


Testing & code coverage

Run the test suite:

Note: The test suite is configured to generate code coverage reports. If you encounter "No code coverage driver available", you'll need to install either Xdebug or PCOV:

Installing a code coverage driver

Option 1: PCOV (recommended for performance)

Then add to your php.ini:

Option 2: Xdebug

Then add to your php.ini:

Run tests without coverage:


Examples

Retry with sequence + jitter + follow headers

Hedged requests

Deciders: retry on 4xx/5xx or named tags


Contributing


License

MIT (see LICENSE).


All versions of rtry with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
gohany/retry Version ^1.0
psr/clock Version ^1.0
psr/http-message Version ^1.0 || ^2.0
ext-ctype Version *
psr/log Version ^1 || ^2 || ^3
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 gohany/rtry contains the following files

Loading the files please wait ...