yucadoo/bgy-neighborhoods-diagnostic

Error detection strategy for Boris Guéry's transient error handling using Neighborhoods' throwable diagnostic component.

0.0.1 2020-10-18 16:32 UTC

This package is auto-updated.

Last update: 2024-12-19 01:41:43 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Error detection strategy for Boris Guéry's transient error handling using Neighborhoods' throwable diagnostic component.

Install

Via Composer

$ composer require yucadoo/bgy-neighborhoods-diagnostic

Usage

use Bgy\TransientFaultHandling\RetryPolicy;
use Bgy\TransientFaultHandling\RetryStrategies\FixedInterval;
use YucaDoo\BgyNeighborhoodsDiagnostic\ExceptionDetectionStrategy as NeighborhoodsErrorDetectionStrategy;

/**
 * Obtain a preconfigured ThrowableDiagnostic builder factory.
 * You can use Symfony DI as explained in Neighborhoods' throwable diagnostic component.
 */
$throwableDiagnosticBuilderFactory = $container->get('ThrowableDiagnosticBuilderFactoryWithTailoredDecoratorStack');

$neighborhoodsErrorDetectionStrategy = new NeighborhoodsErrorDetectionStrategy();
$neighborhoodsErrorDetectionStrategy->setThrowableDiagnosticBuilderFactory($throwableDiagnosticBuilderFactory);

// Compose retry policy
$retryCount = 10;
$retryIntervalInMicroseconds = 1000000 // 1 sec 
$retryStrategy = new FixedInterval($retryCount, $retryIntervalInMicroseconds);
$retryPolicy = new RetryPolicy($neighborhoodsErrorDetectionStrategy, $retryStrategy);

$retryPolicy->execute(function() {
    // API calls
    // Database calls
});

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email hrcajuka@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.