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-10-19 15:07:20 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());