定制 kelunik/retry 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kelunik/retry

最新稳定版本:v1.0.0

Composer 安装命令:

composer require kelunik/retry

包简介

A tiny library for retrying failed operations.

README 文档

README

kelunik/retry is a small library for retrying failed operations.

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

统计信息

  • 总下载量: 19.54k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 16
  • 点击次数: 1
  • 依赖项目数: 7
  • 推荐数: 0

GitHub 信息

  • Stars: 16
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-09-22