Download the PHP package ilicmiljan/retry-master without Composer

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

RetryMaster

stability-beta GitHub Workflow Status (with branch) codecov Packagist PHP Version GitHub

RetryMaster is a flexible and extensible PHP library for handling operation retries. It provides a simple, declarative way of managing operations that might fail due to transient issues. By using RetryMaster, you can easily implement robust retry logic with customizable policies for when and how to perform retries.

Features

Table of Contents

Installation

RetryMaster is available as a Composer package. You can add it to your project by running the following command in your terminal:

This will add RetryMaster to your project's dependencies and download the package to your vendor directory.

After installation, you can use RetryMaster classes by adding the appropriate use statements at the top of your PHP files. For example:

Be sure to run composer dump-autoload if you're not using a framework that does this automatically.

Usage

Using RetryMaster in your PHP application involves setting up a RetryTemplate and executing your operation using this template. With the introduction of a builder and interfaces, you can use RetryTemplateBuilder to conveniently create a RetryTemplate. You can customize the retry logic by specifying retry and backoff policies when constructing the RetryTemplate.

Here is a basic example:

In this example, the operation will be retried up to three times (the default maximum attempts) if an exception is thrown. Between each attempt, there will be a fixed delay of one second (the default backoff policy).

Customizing Retry Logic

You can specify custom retry and backoff policies when creating the RetryTemplate using the builder:

In this example, the operation will be retried up to five times, and the delay between attempts will be a random number of milliseconds between 500 and 1500.

Handling Retry Failures

You can provide a recovery callback to handle cases when all retry attempts fail:

Gathering Retry Statistics

You can retrieve statistics about retry operations from the RetryTemplate:

For more usage examples, please refer to the inline comments in each class.

Documentation

Overview

RetryMaster is designed to facilitate the implementation of retry operations in your PHP applications. It provides a set of tools for managing retry logic, including customizable retry and backoff policies and detailed retry statistics.

Retry Policies

A retry policy determines whether an operation should be retried after a failure. RetryMaster includes several built-in retry policies, such as:

You can also create your own retry policies by implementing the RetryPolicy interface.

Backoff Policies

A backoff policy determines the delay between retry attempts. RetryMaster includes several built-in backoff policies, such as:

You can also create your own backoff policies by implementing the BackoffPolicy interface.

Custom Random Implementation

For the ExponentialRandomBackoffPolicy, UniformRandomBackoffPolicy, and any other policies that utilize a random component, you can specify your own custom random generation logic by creating a class that implements the Random interface. This provides the flexibility to adapt the random behavior to specific requirements of your application or environment.

The backoff policies in RetryMaster are designed with flexibility in mind and by default they utilize the RandomGenerator implementation provided within the library.

Retry Statistics

The RetryStatistics interface allows you to gather information about retry operations, such as the total number of attempts, the number of successful attempts, the number of failed attempts, and the total sleep time. You can use the provided InMemoryRetryStatistics implementation or create your own.

Retry and Recovery Callbacks

You can define custom logic to execute on each retry attempt and when all retries fail by implementing the RetryCallback and RecoveryCallback interfaces, respectively.

RetryTemplate

The RetryTemplate class simplifies the process of executing operations with retry logic. You provide the operation logic and the RetryTemplate handles the retries according to the configured retry and backoff policies.

Sleeping

The Sleeper interface in RetryMaster is a powerful tool for implementing delay mechanisms in your retry operations. It provides a method to halt the execution of a script for a specified number of milliseconds. It's particularly useful when implementing backoff policies, simulating network latency in testing environments, or throttling requests to a third-party service.

You can replace default NanoSleeper by providing your own implementation in your RetryTemplate:

By customizing the Sleeper interface in your RetryTemplate, you have full control over how your application handles delays and sleeping intervals, allowing for precise and effective management of your retry operations.

Logging

RetryMaster comes with an integrated logging system that you can use to monitor and debug your retry operations. It uses the PSR-3 Logger Interface, making it compatible with most logging libraries.

You can set up logging by providing a logger to your RetryTemplate:

License

RetryMaster is licensed under the MIT License. This means you can use and modify the code freely as long as you include the original copyright and permission notice in any copy of the software/source.

Credits

RetryMaster is developed and maintained by @IlicMiljan. It's a product of many hours of hard work and dedication, and contributions from the open-source community are greatly appreciated.

This library is greatly inspired by the Spring Retry library, a part of the Spring Framework for Java. The design principles and structure of Spring Retry have been instrumental in shaping RetryMaster. If you're familiar with Spring Retry, you will find many similarities in RetryMaster.

Special thanks to the team behind the Spring Retry library for their impressive work, which serves as a foundation for this project. Their commitment to creating robust and flexible solutions for retry operations has been a significant inspiration.

Finally, a big thank you to all contributors and users of RetryMaster. Your feedback, bug reports, and feature suggestions are invaluable in making this library better. If you would like to contribute, please feel free to submit a pull request.


All versions of retry-master with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
psr/log Version ^3.0
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 ilicmiljan/retry-master contains the following files

Loading the files please wait ....