Last updated:
0 purchases
etcd
A client library for connecting to and interacting with ETCD, a distributed, reliable key-value store for the most critical data of a distributed system
Usage #
Create a client:
var client = new EtcdClient('etcd.example.com', port: 2379, options: new ChannelOptions(credentials: ChannelCredentials.insecure()));
copied to clipboard
Fetch a value:
var currentValue = await client.kv.fetch('myKey');
copied to clipboard
Set/Update a value:
await client.kv.put('myKey', 'myValue');
copied to clipboard
Attach a lease to a value:
var lease = await client.lease.grant(Duration(seconds: 5));
await client.kv.put('myKey', 'myValue', lease: lease.id);
copied to clipboard
Check remaining time on a lease:
var remainingTTL = await client.lease.timeToLive(lease.id, listKeys: true);
copied to clipboard
Renew a lease:
await lease.keepAlive();
copied to clipboard
Revoke a lease (and the values its attached to):
await client.lease.revoke(lease.id);
copied to clipboard
Watch a value for changes:
var watcher = await client.watch.single(KEY, prevKv: true);
watcher.listen((EtcdWatchEvent event) {
switch (event.type) {
case EtcdWatchEventType.PUT:
print('Key `${event.kv.key}` modified: replaced value `${event.prevKv.value}` with `${event.kv.value}`');
break;
case EtcdWatchEventType.DELETE:
print('Key `${event.kv.key}` was deleted: deleted value was `${event.prevKv.value}`');
break;
}
});
copied to clipboard
Features and bugs #
For now, please file feature requests and bugs by emailing the author
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.