2017 © Pedro Peláez
 

library retry

A tiny library for retrying failed operations.

image

kelunik/retry

A tiny library for retrying failed operations.

  • Friday, September 22, 2017
  • by kelunik
  • Repository
  • 2 Watchers
  • 9 Stars
  • 35 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 17 % Grown

The README.md

retry

kelunik/retry is a small library for retrying failed operations., (*1)

Installation

composer require kelunik/retry

Usage

<?php

use Amp\Loop;
use Kelunik\Retry\ConstantBackoff;
use function Kelunik\Retry\retry;

require __DIR__ . "/../vendor/autoload.php";

Loop::run(function () {
    /** @var Amp\Socket\ClientSocket $socket */
    $socket = yield retry(3, function () {
        return Amp\Socket\cryptoConnect("tcp://github.com:443");
    }, Amp\Socket\SocketException::class, new ConstantBackoff(1000));

    yield $socket->write("GET / HTTP/1.0\r\nhost: github.com\r\n\r\n");

    $buffer = "";

    while (null !== $chunk = yield $socket->read()) {
        $buffer .= $chunk;

        if (strpos($buffer, "\r\n\r\n") !== false) {
            print strstr($buffer, "\r\n\r\n", true);
            break;
        }
    }

    $socket->close();
});

The Versions

22/09 2017

dev-master

9999999-dev

A tiny library for retrying failed operations.

  Sources   Download

MIT

The Requires

 

The Development Requires

22/09 2017

v1.0.0

1.0.0.0

A tiny library for retrying failed operations.

  Sources   Download

MIT

The Requires

 

The Development Requires