Skip to content

hotrush/scrapoxy-react-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!

About

Async client for Scrapoxy and ReactPHP

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages