moln/failover-manager

Any resources failover, Redis, tcp

1.4.0 2016-10-26 05:49 UTC

This package is auto-updated.

Last update: 2024-11-19 15:17:26 UTC


README

Build Status Latest Stable Version

Resource failover manager 资源故障转移管理器

安装Installation using Composer

{
    "require": {
        "moln/failover-manager": "^1.0"
    }
}

Example - 使用举例

include '../vendor/autoload.php';

$resources = new \Moln\FailoverManager\ResourceManager(
    [
        'resources' => [
            'master' => [
                'type' => 'redis',
                'options' => [
                    'server' => 'tcp://192.168.177.10:6379?password=111'
                ]
            ],
            'slave1' => [
                'type' => 'redis',
                'options' => [
                    'server' => 'tcp://192.168.177.10:6379?password=222'
                ]
            ],
        ],
        'listeners' => [
            new \Moln\FailoverManager\Listener\FileConfigFailoverListener(['file' => 'failover.json']),
        ]
    ]
);

$resource = $resources->getRandomResource();
/** @var \Redis $redis */
$redis = $resource->getResource();

print_r($redis->info());
print_r($resource->getServer());