yucadoo/bgy-neighborhoods-diagnostic

使用Neighborhoods的可抛诊断组件,为Boris Guéry的瞬态错误处理提供错误检测策略。

0.0.1 2020-10-18 16:32 UTC

This package is auto-updated.

Last update: 2024-09-19 01:12:48 UTC


README

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

使用Boris Guéry的瞬态错误处理Neighborhoods的可抛诊断组件进行错误检测的策略。

安装

通过Composer

$ composer require yucadoo/bgy-neighborhoods-diagnostic

用法

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
});

测试

$ composer test

贡献

请参阅CONTRIBUTINGCODE_OF_CONDUCT以获取详细信息。

安全

如果您发现任何安全相关的问题,请通过hrcajuka@gmail.com发送电子邮件,而不是使用问题跟踪器。

鸣谢

许可证

MIT许可证(MIT)。有关更多信息,请参阅许可证文件