s1lver / yii2-etcd
Yii2 etcd component
Installs: 29
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 1
Type:yii2-extension
Requires
- php: ^8.0
- ext-curl: *
- google/protobuf: ^v3.11.4
- grpc/grpc: ^1.42.0
- guzzlehttp/guzzle: ^7.4.5
Requires (Dev)
- roave/security-advisories: dev-latest
- yiisoft/yii2: ^2.0.45
Suggests
- ext-grpc: Needed for the grpc protocol to work
README
Interaction component with etcd
(A distributed, reliable key-value store for the most critical data of a distributed system) for Yii2 Framework
.
Required
- PHP: >= 8.0
- grpc - for RPC
- protobuf - for RPC
Install
composer require s1lver/yii2-etcd "^1.0.0"
or add
"s1lver/yii2-etcd": "^1.0.0"
to the require section of your composer.json file.
Supported etcd API version
- v3
Supported etcd methods
Main
version
KV
range
put
Auth
authenticate
How to use
Configure
$config = [ 'components' => [ 'etcd' => [ 'class' => \S1lver\Etcd\Etcd::class, 'host' => 'etcd:2379', 'user' => 'username', 'password' => 'password', ], ], ];
Get key value
Yii::$app->etcd->getKey('hello')->firstKeyValue; // Hello
Get etcd version
Yii::$app->etcd->version; // {"etcdserver":"3.5.8","etcdcluster":"3.5.0"}
Switch between supported protocol
etcd v3 uses gRPC for its messaging protocol. For languages with no gRPC support, etcd provides a JSON gRPC gateway. This gateway serves a RESTful proxy that translates HTTP/JSON requests into gRPC messages.
$config = [ 'components' => [ 'etcd' => [ 'class' => \S1lver\Etcd\Etcd::class, ... 'protocol' => '\S1lver\Etcd\EtcdProtocol::GRPC', // Default value \S1lver\Etcd\EtcdProtocol::HTTP ], ], ];