hotrush / scrapoxy-react-client
Async client for Scrapoxy and ReactPHP
1.1.0
2018-04-10 11:06 UTC
Requires
- php: >=7.1
- react/dns: 0.4.*
- react/event-loop: 0.5.*
- react/http: 0.8.*
- react/http-client: 0.5.*
- react/promise: ~2.5
Requires (Dev)
- phpunit/phpunit: ^6.0
README
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!