PHP code example of aedart / athenaeum-circuits

1. Go to this page and download the library: Download aedart/athenaeum-circuits library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aedart / athenaeum-circuits example snippets




use Aedart\Circuits\Traits\CircuitBreakerManagerTrait;

class WeatherService
{
    use CircuitBreakerManagerTrait;

    public function forecast()
    {
        $circuitBreaker = $this->getCircuitBreakerManager()
                ->create('weather_service');

        return $circuitBreaker->attempt(function() {
            // Perform 3rd party API call... not shown here
        }, function(){
            // Service has failed and is unavailable, do something else...
        });
    }
}