, (*1)
, (*2)
Supervisor API Client, (*3)
ToDo:
- documentation
- example
- etc., (*4)
Example of a simple way to create a client manager., (*5)
<?php
use FragSeb\Supervisor\Factory\ManagerFactory;
/** @var Composer\Autoload\ClassLoader $loader */
$loader = require __DIR__.'/../vendor/autoload.php';
$config = [
'master' => [
'host' => 'http://localhost:9001/RPC2',
'auth' => [
'username' => 'user',
'password' => 123
]
],
'slave' => [
'host' => 'http://localhost2:9001/RPC2',
'auth' => [
'username' => 'user',
'password' => 123
]
]
];
$factory = new ManagerFactory();
$manager = $factory->create($config);
try {
$client = $manager;
var_dump($client->getAllProcessInfo());
} catch (\Exception $exception) {
echo 'message: ' . $exception->getMessage() . PHP_EOL;
echo 'code: ' . $exception->getCode() . PHP_EOL;
exit;
}
Example for multi server call., (*6)
<?php
use FragSeb\Supervisor\Factory\ClientFactory;
use FragSeb\Supervisor\Factory\XmlRpcConnectorFactory;
use FragSeb\Supervisor\Serializer\XmlRpcSerializer;
use FragSeb\Supervisor\Registry\ServerRegistry;
use FragSeb\Supervisor\Registry\ClientRegistry;
use FragSeb\Supervisor\ClientManager;
use FragSeb\Supervisor\Factory\ServerFactory;
use FragSeb\Supervisor\Response\ResponseBuilder;
/** @var Composer\Autoload\ClassLoader $loader */
$loader = require __DIR__.'/../vendor/autoload.php';
$config = [
'master' => [
'host' => 'http://localhost:9001/RPC2',
'auth' => [
'username' => 'user',
'password' => 123
]
],
'slave' => [
'host' => 'http://localhost2:9001/RPC2',
'auth' => [
'username' => 'user',
'password' => 123
]
]
];
$clientRegistry = new ClientRegistry(
new ServerRegistry($config, new ServerFactory),
new XmlRpcConnectorFactory(new XmlRpcSerializer),
new ClientFactory(new ResponseBuilder)
);
/** @var \FragSeb\Supervisor\Client\ClientInterface $manager */
$manager = new ClientManager($clientRegistry);
try {
var_dump($manager->getAllProcessInfo());
} catch (\Exception $exception) {
echo 'message: ' . $exception->getMessage() . PHP_EOL;
echo 'code: ' . $exception->getCode() . PHP_EOL;
exit;
}
Example for single call., (*7)
<?php
use FragSeb\Supervisor\Factory\ClientFactory;
use FragSeb\Supervisor\Factory\XmlRpcConnectorFactory;
use FragSeb\Supervisor\Serializer\XmlRpcSerializer;
use FragSeb\Supervisor\Registry\ServerRegistry;
use FragSeb\Supervisor\Registry\ClientRegistry;
use FragSeb\Supervisor\ClientManager;
use FragSeb\Supervisor\Factory\ServerFactory;
use FragSeb\Supervisor\Response\ResponseBuilder;
/** @var Composer\Autoload\ClassLoader $loader */
$loader = require __DIR__.'/../vendor/autoload.php';
$config = [
'master' => [
'host' => 'http://localhost:9001/RPC2',
'auth' => [
'username' => 'user',
'password' => 123
]
],
'slave' => [
'host' => 'http://localhost2:9001/RPC2',
'auth' => [
'username' => 'user',
'password' => 123
]
]
];
$clientRegistry = new ClientRegistry(
new ServerRegistry($config, new ServerFactory),
new XmlRpcConnectorFactory(new XmlRpcSerializer),
new ClientFactory(new ResponseBuilder)
);
/** @var \FragSeb\Supervisor\Client\ClientInterface $manager */
$manager = new ClientManager($clientRegistry);
try {
$client = $manager->getClient('master');
var_dump($client->getAllProcessInfo());
} catch (\Exception $exception) {
echo 'message: ' . $exception->getMessage() . PHP_EOL;
echo 'code: ' . $exception->getCode() . PHP_EOL;
exit;
}