indigerd/http-fault-tolerance 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

indigerd/http-fault-tolerance

Composer 安装命令:

composer require indigerd/http-fault-tolerance

包简介

Handle http requests with custom fallback strategies

README 文档

README

Usage

Example of simple usage (by default when http request will fail library will make 1 more attempt to make http request)

use Indigerd\Tolerance\Client;
use GuzzleHttp\Client as HttpClient;
use Indigerd\Tolerance\Fallback\FallbackFactory;
use Indigerd\Tolerance\ResponseFactory;

$client = new Client(new HttpClient(), new FallbackFactory(), new ResponseFactory());
$response = $client->request('GET', 'http://facebook.com');
echo($response->getBody());

Example of using with Complex fallback strategy. Complex fallback strategy is a collection of fallbacks that will be called untill one will succeed.

use Indigerd\Tolerance\Client;
use GuzzleHttp\Client as HttpClient;
use Indigerd\Tolerance\Fallback\FallbackFactory;
use Indigerd\Tolerance\ResponseFactory;

$client = new Client(new HttpClient(), new FallbackFactory(), new ResponseFactory());
$strategy = new \Indigerd\Tolerance\Fallback\Strategy\Complex(
    ['retry', new \Indigerd\Tolerance\Fallback\Strategy\Fixture('GGGGGG')],
    new FallbackFactory()
);
$response = $client->request('GET', 'http://google344534534534534534111111.com', [], $strategy);
echo($response->getBody());

Example of using library client instead of Guzzle by creating Guzzle decarator. As decorator extends Guzzle Http client you can just inject it in your code with dependency injection without changing your business logic.

use Indigerd\Tolerance\Decorator\GuzzleHttp\Client;

$client = new Client();

统计信息

  • 总下载量: 613
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-05-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固