Download the PHP package ackintosh/ganesha without Composer

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

Ganesha

Ganesha is PHP implementation of Circuit Breaker pattern which has multi strategies to avoid cascading failures and supports various storages to record statistics.

![ganesha](https://ackintosh.github.io/assets/images/ganesha.png) [![Latest Stable Version](https://img.shields.io/packagist/v/ackintosh/ganesha.svg?style=flat-square)](https://packagist.org/packages/ackintosh/ganesha) [![Tests](https://github.com/ackintosh/ganesha/workflows/Tests/badge.svg)](https://github.com/ackintosh/ganesha/actions) [![Coverage Status](https://coveralls.io/repos/github/ackintosh/ganesha/badge.svg?branch=master)](https://coveralls.io/github/ackintosh/ganesha?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ackintosh/ganesha/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ackintosh/ganesha/?branch=master) [![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.0-8892BF.svg?style=flat-square)](https://php.net/)
**If Ganesha is saving your service from system failures, please consider [supporting](https://github.com/sponsors/ackintosh) to this project's author, [Akihito Nakano](#author), to show your :heart: and support. Thank you!** [Sponsor @ackintosh on GitHub Sponsors](https://github.com/sponsors/ackintosh)

This is one of the Circuit Breaker implementation in PHP which has been actively developed and production ready - well-tested and well-documented. :muscle: You can integrate Ganesha to your existing code base easily as Ganesha provides just simple interfaces and Guzzle Middleware behaves transparency.

If you have an idea about enhancement, bugfix..., please let me know via Issues. :sparkles:

Table of contents

Are you interested?

Here is an example which shows you how Ganesha behaves when a failure occurs.
It is easily executable. All you need is Docker.

Unveil Ganesha

Usage

Ganesha provides following simple interfaces. Each method receives a string (named $service in example) to identify the service. $service will be the service name of the API, the endpoint name, etc. Please remember that Ganesha detects system failure for each $service.

Three states of circuit breaker

(martinfowler.com : CircuitBreaker)

Ganesha follows the states and transitions described in the article faithfully. $ganesha->isAvailable() returns true if the circuit states on Closed, otherwise it returns false.

Subscribe to events in ganesha

Disable

If disabled, Ganesha keeps to record success/failure statistics, but Ganesha doesn't trip even if the failure count reached to a threshold.

Reset

Resets the statistics saved in a storage.

Strategies

Ganesha has two strategies which avoids cascading failures.

Rate

Note about "time window": The Storage Adapter implements either SlidingTimeWindow or TumblingTimeWindow. The difference of the implementation comes from constraints of the storage functionalities.

[SlidingTimeWindow]

The details to help us understand visually is shown below:
(quoted from Introduction to Stream Analytics windowing functions - Microsoft Azure)

[TumblingTimeWindow]

The details to help us understand visually is shown below:
(quoted from Introduction to Stream Analytics windowing functions - Microsoft Azure)

Count

If you prefer the Count strategy use Builder::buildWithCountStrategy() to build an instance.

Adapters

APCu

The APCu adapter requires the APCu extension.

Note: APCu is internal to each server/instance, not pooled like most Memcache and Redis setups. Each worker's circuit breaker will activate or reset individually, and failure thresholds should be set lower to compensate.

Redis

Redis adapter requires phpredis or Predis client instance. The example below is using phpredis.

Memcached

Memcached adapter requires memcached (NOT memcache) extension.

MongoDB

MongoDB adapter requires mongodb extension.

Customizing storage keys

If you want to customize the keys to be used when storing circuit breaker information, set an instance which implements StorageKeysInterface.

Ganesha :heart: Guzzle

If you are using Guzzle (v6 or higher), Guzzle Middleware powered by Ganesha makes it easy to integrate Circuit Breaker to your existing code base.

How does Guzzle Middleware determine the $service?

As documented in Usage, Ganesha detects failures for each $service. Below, We will show you how Guzzle Middleware determine $service and how we specify $service explicitly.

By default, the host name is used as $service.

You can also specify $service via a option passed to client, or request header. If both are specified, the option value takes precedence.

Alternatively, you can apply your own rules by implementing a class that implements the ServiceNameExtractorInterface.

How does Guzzle Middleware determine the failure?

By default, if the next handler promise is fulfilled ganesha will consider it a success, and a failure if it is rejected.

You can implement your own rules on fulfilled response by passing an implementation of FailureDetectorInterface to the middleware.

Ganesha :heart: OpenAPI Generator

PHP client generated by OpenAPI Generator is using Guzzle as HTTP client and as we mentioned as Ganesha :heart: Guzzle, Guzzle Middleware powered by Ganesha is ready. So it is easily possible to integrate Ganesha and the PHP client generated by OpenAPI Generator in a smart way as below.

Ganesha :heart: Symfony HttpClient

If you are using Symfony HttpClient, GaneshaHttpClient makes it easy to integrate Circuit Breaker to your existing code base.

How does GaneshaHttpClient determine the $service?

As documented in Usage, Ganesha detects failures for each $service. Below, We will show you how GaneshaHttpClient determine $service and how we specify $service explicitly.

By default, the host name is used as $service.

You can also specify $service via a option passed to client, or request header. If both are specified, the option value takes precedence.

Alternatively, you can apply your own rules by implementing a class that implements the ServiceNameExtractorInterface.

How does GaneshaHttpClient determine the failure?

As documented in Usage, Ganesha detects failures for each $service. Below, We will show you how GaneshaHttpClient specify failure explicitly.

By default, Ganesha considers a request is successful as soon as the server responded, whatever the HTTP status code.

Alternatively, you can use the RestFailureDetector implementation of FailureDetectorInterface to specify a list of HTTP Status Code to be considered as failure via an option passed to client.
This implementation will consider failure when these HTTP status codes are returned by the server:

Alternatively, you can apply your own rules by implementing a class that implements the FailureDetectorInterface.

Companies using Ganesha :rocket:

Here are some companies using Ganesha in production! We are proud of them. :elephant:

To add your company to the list, please visit README.md and click on the icon to edit the page or let me know via issues/twitter.

(alphabetical order)

The articles/videos Ganesha loves :sparkles: :elephant: :sparkles:

Here are some articles/videos introduce Ganesha! All of them are really shining like a jewel for us. :sparkles:

Articles

Videos

Run tests

We can run unit tests on a Docker container, so it is not necessary to install the dependencies in your machine.

Requirements

Version Guidance

Version PHP Version
3.x >=8.0
2.x >=7.3
1.x >=7.1
0.x >=5.6

Author

Ganesha © ackintosh, Released under the MIT License.
Authored and maintained by ackintosh

GitHub @ackintosh / Twitter @NAKANO_Akihito / Blog (ja)


All versions of ganesha with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
psr/http-message Version ^1.0|^2.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 ackintosh/ganesha contains the following files

Loading the files please wait ....