hotrush/scrapoxy-react-client

Async client for Scrapoxy and ReactPHP

1.1.0 2018-04-10 11:06 UTC

This package is auto-updated.

Last update: 2024-12-25 08:24:57 UTC


README

Build Status Coverage Status StyleCI Version Packagist Downloads SensioLabsInsight

Scrapoxy-React-Client

Async client for Scrapoxy and ReactPHP.

Installation

composer require hotrush/scrapoxy-react-client

Usage

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

Get scaling

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

Will output your current scaling info:

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

Scaling up and down

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

Scaling up will update required instances number to maximum. Scaling down will update it to minimum.

Custom scaling

You can define your custom instances number:

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

Get and update config

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

Get instances

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

Stop instance by name

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

Will throw NotFoundException if instance name not found.

Contribution

You are welcome to create any pull requests or write some tests!