PHP code example of yucadoo / bgy-neighborhoods-diagnostic

1. Go to this page and download the library: Download yucadoo/bgy-neighborhoods-diagnostic 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/ */

    

yucadoo / bgy-neighborhoods-diagnostic example snippets

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