2017 © Pedro Peláez
 

library yolo

Advanced Retry Implementation

image

gos/yolo

Advanced Retry Implementation

  • Tuesday, September 29, 2015
  • by ProPheT777
  • Repository
  • 3 Watchers
  • 3 Stars
  • 560 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Yolo

Advanced retry implementation., (*1)

Installation

composer require gos/yolo

Example

Perform an action, (*2)

$pusher->push($notification); #send notification over network

With YOLO :, (*3)

use Gos\Component\Yolo\Yolo;

$maxRetry = 10; // Default is 5
$timeout = 10; // Default is 5 (in second), set 0 for not timeout
$allowedException = ['RuntimeException']; // empty by default, consider exception as a "success"
$yoloPush = new Yolo(array($pusher, 'push'), array($notification), $maxRetry, $timeout);
$yoloPush->run();

Sometimes we need more swag to retry over a webservice., (*4)

use Gos\Component\Yolo\Yolo;

$yoloPush = new Yolo(array($pusher, 'push'), array($notification));
$yoloPush->tryUntil(function(){
    $result = false;
    if ($fp = @fsockopen('my-web-service.dev', 1337, $errCode, $errStr, 1)) {
        $result = true;
        fclose($fp);
    }

    return $result;
});

If your operation have an hight cost, perform it when service is available instead of dummy retry., (*5)

You also can do :, (*6)

use Gos\Component\Yolo\Yolo;

$yoloPush = new Yolo(array($pusher, 'push'), array($notification));
$yoloPush->tryUntil($pusher);

By implementing Gos\Component\Yolo\YoloInterface on your object. Add isAvailable and return true when it's ok., (*7)

You also can attach a logger to yolo (We implement Psr\Log\LoggerAwareInterface) . Swag, (*8)

use Gos\Component\Yolo\Yolo;

$yolo = new Yolo(function(){});
$yolo->setLogger($mySwagPsrLogger);

Built in Callback

Ping Back

use Gos\Component\Yolo\Yolo;
use Gos\Component\Yolo\Callback\PingBack;

$pingger = new PingBack('127.0.0.1', 80);

$yoloPush = new Yolo(function(){});
$yoloPush->tryUntil($pingger);

The Versions

29/09 2015

dev-master

9999999-dev https://github.com/GeniusesOfSymfony/Yolo

Advanced Retry Implementation

  Sources   Download

MIT

The Requires

 

by Johann Saunier

handler retry yolo

29/09 2015

v0.2.2

0.2.2.0 https://github.com/GeniusesOfSymfony/Yolo

Advanced Retry Implementation

  Sources   Download

MIT

The Requires

 

by Johann Saunier

handler retry yolo

23/06 2015

v0.2.1

0.2.1.0 https://github.com/GeniusesOfSymfony/Yolo

Advanced Retry Implementation

  Sources   Download

MIT

The Requires

 

by Johann Saunier

handler retry yolo

09/06 2015

v0.2.0

0.2.0.0 https://github.com/GeniusesOfSymfony/Yolo

Advanced Retry Implementation

  Sources   Download

MIT

The Requires

 

by Johann Saunier

handler retry yolo

01/06 2015

v0.1.0

0.1.0.0 https://github.com/GeniusesOfSymfony/Yolo

Advanced Retry Implementation

  Sources   Download

MIT

The Requires

 

by Johann Saunier

handler retry yolo