hotrush/scrapoxy-react-client

Scrapoxy 和 ReactPHP 的异步客户端

1.1.0 2018-04-10 11:06 UTC

This package is auto-updated.

Last update: 2024-09-25 07:48:02 UTC


README

Build Status Coverage Status StyleCI Version Packagist Downloads SensioLabsInsight

Scrapoxy-React-Client

Scrapoxy 和 ReactPHP 的异步客户端。

安装

composer require hotrush/scrapoxy-react-client

使用方法

use Hotrush\ScrapoxyClient\Client;
use React\EventLoop\Factory as LoopFactory;

$loop = LoopFactory::create();
$client = new Client('http://scrapoxy-host.com/api/', 'password', $loop);
$loop->run();

获取缩放

$client->getScaling()
    ->then(
        function($scaling) {
            var_dump($scaling);
        },
        function($exception) {
            echo (string) $exception;
        }
    );

将输出您的当前缩放信息

[
    "min" => 0,
    "required" => 2,
    "max" => 5,
]

缩放上下调整

$client->upScale()->then(...);
$client->downScale()->then(...);

缩放上升将更新所需实例数量至最大值。缩放下降将更新至最小值。

自定义缩放

您可以定义自定义实例数量

$client->scale([
    'min' => 0,
    'max' => 10,
    'required' => 5,
]);

获取和更新配置

$client->getConfig()->then(...);
$client->updateConfig([
    'any_key' => 'any_value',
])->then(...);

获取实例

$client->getInstances()->then(...);

按名称停止实例

$client->stopInstance($name)->then(...);

如果未找到实例名称,将抛出 NotFoundException

贡献

欢迎创建任何 pull requests 或编写一些测试!