亚洲精品成人_精品成人一区_999视频在线播放_免费黄色在线_亚洲成人久久久_久久www免费视频

Etcd 協程客戶端

EasySwoole 提供了一個協程安全的 Etcd 協程版本客戶端,方便用戶做分布式及微服務開發。

組件要求

  • php: >= 7.1.0
  • ext-json: *
  • easyswoole/http-client: ^1.1

安裝方法

composer require easyswoole/etcd-client

倉庫地址

easy-swoole/etcd-client

使用方式

使用如下方式,先給 Etcd 客戶端注入 Config 連接配置,連接上 Etcd 服務端。

<?php
require_once 'vendor/autoload.php';

// config 默認 http://127.0.0.1:2379/v3
### 數組形式注入配置
$config = new \EasySwoole\EtcdClient\Config([
    'host'    => '127.0.0.1',
    'port'    => 6379,
    'scheme'  => 'http',
    'version' => 'v3', // v3alpha v3beta v3 v2
    'pretty'  => true,
    'ssl'     => false,
]);

### setter 形式注入配置
$config->setHost('127.0.0.1');
$config->setPort(2379);
$config->setScheme('http');
$config->setVersion('v3'); // v3alpha v3beta v3 v2
$config->setPretty(true);
$config->setSsl(false);

// 數組形式 和 setter 形式兩種寫法,最終效果是相同的

$etcd = new \EasySwoole\EtcdClient\Etcd($config);

$client = $etcd->client();

下文所用到的 $client 都是引用上述連接上的客戶端。

KV

set

<?php
go(function () use ($client) {
    // set value
    $client->put('redis', '127.0.0.1:6379');

    // set value and return previous value
    $client->put('redis', '127.0.0.1:6579', ['prev_kv' => true]);

    // set value with lease
    $client->put('redis', '127.0.0.1:6579', ['lease' => 7587822882194199413]);
});

get

<?php
go(function () use ($client) {
    // get key value
    $client->get('redis');

    // get all keys
    $client->getAllKeys();

    // get keys with prefix
    $client->getKeysWithPrefix('/v3/service/user/');
});

delete

<?php
go(function () use ($client) {
    // delete key
    $client->del('redis');
});

compaction

<?php
go(function () use ($client) {
    // compaction
    $client->compaction(7);
});

Lease

<?php
go(function () use ($client) {
    // grant with ID 0
    $client->grant(3600);

    // grant with ID
    $client->grant(3600, 7587822882194199413);

    // revoke a lease
    $client->revoke(7587822882194199413);

    // keep the lease alive
    $client->keepAlive(7587822882194199413);

    // retrieve lease information
    $client->timeToLive(7587822882194199413);
});

Auth Role User

<?php
go(function () use ($client) {
    // enable authentication
    $client->authEnable();

    // disable authentication
    $client->authDisable();

    // get auth token
    $token = $client->authenticate('user', 'password');

    // set auth token
    $client->setToken($token);

    // clear auth token
    $client->clearToken();

    // add a new role
    $client->addRole('root');

    // get detailed role information
    $client->getRole('root');

    // delete a specified role
    $client->deleteRole('root');

    // get lists of all roles
    $client->roleList();

    // add a new user
    $client->addUser('user', 'password');

    // get detailed user information
    $client->getUser('root');

    // delete a specified user
    $client->deleteUser('root');

    // get a list of all users.
    $client->userList();

    // change the password of a specified user
    $client->changeUserPassword('user', 'new password');

    // grant a role to a specified user
    $client->grantUserRole('user', 'role');

    // revoke a role of specified user
    $client->revokeUserRole('user', 'role');

    // grant a permission of a specified key or range to a specified role
    $client->grantRolePermission('admin', \EasySwoole\EtcdClient\Etcd::PERMISSION_READWRITE, 'redis');

    // revoke a key or range permission of a specified role
    $client->revokeRolePermission('admin', 'redis');
});
主站蜘蛛池模板: 欧美日韩国产在线播放 | 国产精品一区二区久久精品爱微奶 | 欧美日本网站 | 91免费视频网址 | 亚洲第一综合网站 | 国产成人久久久精品免费澳门 | 古色传香总部 | 欧美精品在线免费 | 亚欧洲乱码视频 | 香蕉影视app | 成年人在线免费看的惊悚动作片 | 日本高潮视频 | 上柴发电机厂家电话 | 天天操伊人 | 一区久久久 | 99精品在线 | 国产午夜精品在线 | 在线综合视频 | 中文字幕在线免费 | 九九热精品在线播放 | 精品人伦一区二区三区蜜桃免费 | 黄页大全在线观看 | 亚洲精品美女久久久 | 亚洲免费视频网 | 国产日韩网站 | 国产99久久久国产精品免费高清 | 国产麻豆一级片 | www.com色| 性爱视频欧美 | 国产成人久久久精品免费澳门 | 亚洲国产一区二区三区在线观看 | 欧美激情在线看 | 欧日韩不卡视频 | 青草综合 | 一本色道久久88综合日韩精品 | 国产精品91久久久久 | 天堂影院在线免费观看电影电视剧 | 人人澡人人草 | 国内精品久久久久久久97牛牛 | 亚洲精品美女久久久 | 亚洲综合成人av |