dotnet-etcd 2.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package dotnet-etcd --version 2.3.0
NuGet\Install-Package dotnet-etcd -Version 2.3.0
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="dotnet-etcd" Version="2.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add dotnet-etcd --version 2.3.0
#r "nuget: dotnet-etcd, 2.3.0"
#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 dotnet-etcd as a Cake Addin
#addin nuget:?package=dotnet-etcd&version=2.3.0

// Install dotnet-etcd as a Cake Tool
#tool nuget:?package=dotnet-etcd&version=2.3.0

dotnet-etcd

alternate text is missing from this package README image

A C# .NET (dotnet) GRPC client for etcd v3+

Build Status Nuget Version Info Nuget Download Info

Supported .NET Versions

  • .NETCoreApp 2.2
  • .NETCoreApp 2.1
  • .NETCoreApp 2.0
  • .NETStandard 2.0
  • .NETFramework 4.7.2
  • .NETFramework 4.7.1
  • .NETFramework 4.7
  • .NETFramework 4.6.2
  • .NETFramework 4.6.1
  • .NETFramework 4.6
  • .NETFramework 4.5.2
  • .NETFramework 4.5.1
  • .NETFramework 4.5

Installing Package

Nuget package is published on nuget.org and can be installed in the following ways :

Nuget Package Manager

Install-Package dotnet-etcd

.NET CLI

dotnet add package dotnet-etcd

Paket CLI

paket add dotnet-etcd

The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Usage :

Add using statement at the top of your class file

using dotnet_etcd;

Client Initialization

No Basic auth or SSL
EtcdClient client = new EtcdClient(<HOSTNAME_STRING>, <PORTNO_INT>);
// E.g.
EtcdClient client = new EtcdClient("127.0.0.1", 2379);
Available Constructor Parameters
  • username - String containing username for etcd basic auth. Default : Empty String
  • password - String containing password for etcd basic auth. Default : Empty String
  • caCert - String containing ca cert when using self signed certificates with etcd. Default : EmptyString
  • clientCert - String containing client cert when using self signed certificates with client auth enabled in etcd. Default : EmptyString
  • clientKey - String containing client key when using self signed certificates with client auth enabled in etcd. Default : EmptyString
  • publicRootCa - Bool depicting whether to use publicy trusted roots to connect to etcd. Default : false.

Operations

A lot of methods have been implemented using etcd's default input/output parameters. I am simplifying a lot of methods by including more overloads as I come across use cases. If you have some, please feel free to raise and issue or a PR 😃

Key-Value Operations
Put a key
client.Put(<KEY_STRING>,<VALUE_STRING>);
// E.g Put key "foo/bar" with value "foobar"
client.Put("foo/bar","barfoo");

await client.PutAsync(<KEY_STRING>,<VALUE_STRING>);
// E.g Put key "foo/bar" with value "foobar" in async
await client.PutAsync("foo/bar","barfoo");
Get a key
client.GetVal(<KEY_STRING>);
// E.g Get key "foo/bar"
client.GetVal("foo/bar");
// To get full etcd response
client.Get("foo/bar");

await client.GetValAsync(<KEY_STRING>);
// E.g. Get key "foo/bar" in async
await client.GetValAsync("foo/bar");
// To get full etcd response
await client.GetAsync("foo/bar");
Get multiple keys with a common prefix
client.GetRange(<PREFIX_STRING>);
// E.g. Get all keys with pattern "foo/*"
client.GetRange("foo/"); 

await client.GetRangeAsync(<PREFIX_STRING>);
// E.g. Get all keys with pattern "foo/*" in async
await client.GetRangeAsync("foo/");
Delete a key
client.Delete(<KEY_STRING>);
// E.g. Delete key "foo/bar"
client.Delete("foo/bar");

await client.DeleteAsync(<KEY_STRING>);
// E.g. Delete key "foo/bar" in async
await client.DeleteAsync("foo/bar");
Delete multiple keys with a common prefix
client.DeleteRange(<PREFIX_STRING>);
// E.g. Delete all keys with pattern "foo/*"
client.DeleteRange("foo/"); 

await client.DeleteRangeAsync(<PREFIX_STRING>);
// E.g. Delete all keys with pattern "foo/*" in async
await client.DeleteRangeAsync("foo/");

Watch Operations

Watch a key
WatchRequest request = new WatchRequest()
{
    CreateRequest = new WatchCreateRequest()
    {
        Key = ByteString.CopyFromUtf8("foo")
    }
};
etcdClient.Watch(request, print);

-------------------------------
// Print function that prints key and value from the watch response
private static void print(WatchResponse response)
{   
    if (response.Events.Count == 0)
    {
        Console.WriteLine(response);
    }
    else
    {
        Console.WriteLine($"{response.Events[0].Kv.Key.ToStringUtf8()}:{response.Events .Kv.Value.ToStringUtf8()}");
    }
}

----------------------------------
// Print function that prints key and value from the minimal watch
// response data 
private static void print(WatchEvent[] response)
{
    foreach(WatchEvent e1 in response)
    {
        Console.WriteLine($"{e1.Key}:{e1.Value}:{e1.Type}");
    }
}

Watch also has a simple overload as follows

etcdClient.Watch("foo", print);

More overloads are also available. You can check them using IntelliSense (Ctrl+Shift+Space). Detailed documentation coming soon.

Cluster Operations

Add a member into the cluster
 MemberAddRequest request = new MemberAddRequest();
 request.PeerURLs.Add("http://example.com:2380");
 request.PeerURLs.Add("http://10.0.0.1:2380");
 MemberAddResponse res = etcdClient.MemberAdd(request);

 // Async
 MemberAddResponse res = await etcdClient.MemberAddAsync(request);

 // Do something with response
Remove an existing member from the cluster
MemberRemoveRequest request = new MemberRemoveRequest
{
    // ID of member to be removed
    ID = 651748107021
};
MemberRemoveResponse res = etcdClient.MemberRemove(request);

// Async
MemberRemoveResponse res = await etcdClient.MemberRemoveAsync(request);

// Do something with response

Update the member configuration

MemberUpdateRequest request = new MemberUpdateRequest
{
    // ID of member to be updated
    ID = 651748107021
};
request.PeerURLs.Add("http://10.0.0.1:2380");
MemberUpdateResponse res = etcdClient.MemberUpdate(request);

// Async
MemberUpdateResponse res = await etcdClient.MemberUpdateAsync(request);

// Do something with response

List all the members in the cluster

MemberListRequest request = new MemberListRequest();
etcdClient.MemberList(request);
MemberListResponse res = etcdClient.MemberList(request);

// Async
MemberListResponse res = await etcdClient.MemberListAsync(request);

// Do something with response
foreach(var member in res.Members)
{
    Console.WriteLine($"{member.ID} - {member.Name} - {member.PeerURLs}");
}

Coming Soon

  • Auth Operations (Add users,roles etc.)
Product 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 is compatible.  netcoreapp2.1 is compatible.  netcoreapp2.2 is compatible.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net45 is compatible.  net451 is compatible.  net452 is compatible.  net46 is compatible.  net461 is compatible.  net462 is compatible.  net463 was computed.  net47 is compatible.  net471 is compatible.  net472 is compatible.  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.

NuGet packages (28)

Showing the top 5 NuGet packages that depend on dotnet-etcd:

Package Downloads
Etcd.Configuration

Get configuration from etcd configuration center.

cm-catalog-etcd

A CM Catalog implementation using etcd.

NetCorePal.Extensions.Snowflake.Etcd

NetCorePal Cloud Framework

etcd.Provider.Cluster.Extensions

etcd客户端扩展,集群客户端刷新

Ocelot.Provider.Etcd.Cluster

Provides Ocelot extensions to use etcd

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
7.0.0-beta 649 1/7/2024
6.2.0-beta 17,047 12/7/2022
6.0.1 67,739 11/9/2022
6.0.0-beta.0 3,375 9/27/2022
5.2.1 121,696 7/16/2022
5.2.0 99,107 3/2/2022
5.1.0 64,225 10/19/2021
5.0.2 27,388 9/6/2021
5.0.2-alpha 694 8/22/2021
5.0.0-alpha 686 8/9/2021
4.2.0 352,618 12/8/2020
4.1.1 81,545 7/12/2020
4.1.0-beta 1,044 5/31/2020
4.0.0-beta 938 5/10/2020
3.2.0 55,551 4/6/2020
3.1.1 10,170 3/21/2020
3.1.0 2,508 2/23/2020
3.0.0.1-beta 1,231 9/6/2019
3.0.0 54,875 9/24/2019
3.0.0-beta 3,205 9/6/2019
3.0.0-alpha 982 8/11/2019
2.3.1 161,842 3/18/2019
2.3.0 1,796 3/9/2019
2.2.0 1,428 2/17/2019
2.1.1 1,571 2/12/2019
2.1.0 1,838 1/27/2019
2.0.1 7,987 12/9/2018
2.0.0 1,742 11/18/2018

1. Add support for Auth operations
2. Inject Headers in all requests
3. Add snapshot support in maintenance calls
4. Add LeaseKeepAlive support
5. Fix rpc exception loop