EtcdGrpcClient 0.0.2
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package EtcdGrpcClient --version 0.0.2
NuGet\Install-Package EtcdGrpcClient -Version 0.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EtcdGrpcClient" Version="0.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EtcdGrpcClient --version 0.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: EtcdGrpcClient, 0.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install EtcdGrpcClient as a Cake Addin #addin nuget:?package=EtcdGrpcClient&version=0.0.2 // Install EtcdGrpcClient as a Cake Tool #tool nuget:?package=EtcdGrpcClient&version=0.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
<img height="90" alt="etcd grpc client" src="https://raw.githubusercontent.com/undernotic/etcdgrpcclient/master/img/logo.png">
Simple yet useful .net etcd v3 grpc client
Installing
https://www.nuget.org/packages/EtcdGrpcClient/
Simple use example
var etcdAddress = new Uri("http://localhost:2381");
var etcdClient = new EtcdClient(etcdAddress);
await etcdClient.Put("key", "value");
var res = await etcdClient.Get("key");
Assert.Equal("value", res);
Api
- Get
await etcdClient.Put("key", "value");
var res = await etcdClient.Get("test3");
Assert.AreEqual("value", res);
- GetRange
//Range with one parameter(prefix) will return all keys with given prefix
Enumerable.Range(0, 3).Select(async x => await etcdClient.Put("key" + x, "value" + x));
var res = await etcdClient.GetRange("key");
Assert.AreEqual(3, res.Count);
//Range with two parameters will return all keys in given range INCLUDING
Enumerable.Range(0, 3).Select(async x => await etcdClient.Put("key" + x, "value" + x));
var res = await etcdClient.GetRange("key0, key1");
Assert.AreEqual(2, res.Count);
- Watch
var resultList = new List<EtcdWatchEvent[]>();
var watcher = await etcdClient.Watch("key");
watcher.Subscribe(e => resultList.Add(e));
await etcdClient.Put("key", "value");
Assert.AreEqual("key", resultList[0][0].Key);
Assert.AreEqual("value", resultList[0][0].Value);
Assert.AreEqual(EvenType.Put, resultList[0][0].Type);
- WatchRange
//Watch with one parameter(prefix) will watch all keys with given prefix
var resultList = new List<EtcdWatchEvent[]>();
var watcher = await etcdClient.WatchRange("key");
watcher.Subscribe(e => resultList.Add(e));
Enumerable.Range(0, 3).Select(async x => await etcdClient.Put("key" + x, "value" + x));
Assert.AreEqual(3, resultList.Count);
//Watch with two parameters will watch all keys in given range INCLUDING
var resultList = new List<EtcdWatchEvent[]>();
Enumerable.Range(0, 3).Select(async x => await etcdClient.Put("key" + x, "value" + x));
var watcher = await etcdClient.WatchRange("test0, test1");
watcher.Subscribe(e => resultList.Add(e));
Assert.AreEqual(2, res.Count);
- DeleteRange
//Delete with one parameter(prefix) will delete all key with given prefix
await etcdClient.Put("test1", string.Empty);
await etcdClient.Put("test2", string.Empty);
var deletedCount = etcdClient.DeleteRange("test");
var getResult = await etcdClient.GetRange("test");
Assert.AreEqual(3, deletedCount);
Assert.AreEqual(0, get.Values.Count);
//Delete with two parameters will delete keys in given range INCLUDING
await etcdClient.Put("test1", string.Empty);
await etcdClient.Put("test2", string.Empty);
await etcdClient.Put("test3", string.Empty);
var deletedCount = etcdClient.DeleteRange("test1", "test2");
var getResult = await etcdClient.GetRange("test");
Assert.AreEqual(2, deletedCount);
Assert.AreEqual(1, get.Values.Count);
- Lease
//Put with lease third parameter is TTL(time to live) in seconds
var leaseId = await etcdClient.PutWithLease("test", "value", 1);
var get = await etcdClient.Get("test");
await Task.Delay(1100);
Assert.ThrowsAsync<Exception>(async () => await etcdClient.Get("test"));
Assert.AreEqual("value", get);
//Keep alive lease to refresh TTL
var leaseId = await etcdClient.PutWithLease("test", "value", 1);
await Task.Delay(1100);
await etcdClient.KeepAliveLease(leaseId);
await Task.Delay(1100);
await etcdClient.KeepAliveLease(leaseId);
await Task.Delay(1100);
var res = await etcdClient.Get("test");
Assert.AreEqual("value", res);
Authors
- Piotr Szymura - undernotic
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Google.Protobuf (>= 3.4.1)
- Grpc (>= 1.6.1)
- Grpc.Core (>= 1.6.1)
- System.Interactive.Async (>= 3.1.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.