EtcdGrpcClient 0.0.2

.NET Standard 2.0
There is a newer version of this package available.
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
#r "nuget: EtcdGrpcClient, 0.0.2"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. 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

<img height="90" alt="etcd grpc client" src="https://raw.githubusercontent.com/undernotic/etcdgrpcclient/master/img/logo.png">

appveyor status NuGet

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

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
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.3 1,097 3/26/2018
0.0.2 746 3/26/2018