dotnet-etcd
2.0.0
A C# .NET (dotnet) GRPC client for etcd v3+.
etcd is a distributed key value store that provides a reliable way to store data across a cluster of machines. It’s open-source and available on GitHub. etcd gracefully handles leader elections during network partitions and will tolerate machine failure, including the leader.
Your applications can read and write data into etcd. A simple use-case is to store database connection details or feature flags in etcd as key value pairs. These values can be watched, allowing your app to reconfigure itself when they change.
Advanced uses take advantage of the consistency guarantees to implement database leader elections or do distributed locking across a cluster of workers.
See the version list below for details.
Install-Package dotnet-etcd -Version 2.0.0
dotnet add package dotnet-etcd --version 2.0.0
<PackageReference Include="dotnet-etcd" Version="2.0.0" />
paket add dotnet-etcd --version 2.0.0
#r "nuget: dotnet-etcd, 2.0.0"
dotnet-etcd
A C# .NET (dotnet) GRPC client for etcd v3+
Supported .NET Versions
- .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 😃
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/");
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.
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/");
Coming Soon
- Auth Operations (Add users,roles etc.)
- ~~Watch support~~ Released v2.0.0 +
dotnet-etcd
A C# .NET (dotnet) GRPC client for etcd v3+
Supported .NET Versions
- .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 😃
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/");
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.
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/");
Coming Soon
- Auth Operations (Add users,roles etc.)
- ~~Watch support~~ Released v2.0.0 +
Release Notes
Add watch support
Dependencies
-
.NETCoreApp 2.0
- Google.Protobuf (>= 3.6.1)
- Grpc.Core (>= 1.16.0)
- Grpc.Tools (>= 1.16.0)
-
.NETCoreApp 2.1
- Google.Protobuf (>= 3.6.1)
- Grpc.Core (>= 1.16.0)
- Grpc.Tools (>= 1.16.0)
-
.NETFramework 4.5
- Google.Protobuf (>= 3.6.1)
- Grpc.Core (>= 1.16.0)
- Grpc.Tools (>= 1.16.0)
-
.NETFramework 4.5.1
- Google.Protobuf (>= 3.6.1)
- Grpc.Core (>= 1.16.0)
- Grpc.Tools (>= 1.16.0)
-
.NETFramework 4.5.2
- Google.Protobuf (>= 3.6.1)
- Grpc.Core (>= 1.16.0)
- Grpc.Tools (>= 1.16.0)
-
.NETFramework 4.6
- Google.Protobuf (>= 3.6.1)
- Grpc.Core (>= 1.16.0)
- Grpc.Tools (>= 1.16.0)
-
.NETFramework 4.6.1
- Google.Protobuf (>= 3.6.1)
- Grpc.Core (>= 1.16.0)
- Grpc.Tools (>= 1.16.0)
-
.NETFramework 4.6.2
- Google.Protobuf (>= 3.6.1)
- Grpc.Core (>= 1.16.0)
- Grpc.Tools (>= 1.16.0)
-
.NETFramework 4.7
- Google.Protobuf (>= 3.6.1)
- Grpc.Core (>= 1.16.0)
- Grpc.Tools (>= 1.16.0)
-
.NETFramework 4.7.1
- Google.Protobuf (>= 3.6.1)
- Grpc.Core (>= 1.16.0)
- Grpc.Tools (>= 1.16.0)
-
.NETFramework 4.7.2
- Google.Protobuf (>= 3.6.1)
- Grpc.Core (>= 1.16.0)
- Grpc.Tools (>= 1.16.0)
-
.NETStandard 2.0
- Google.Protobuf (>= 3.6.1)
- Grpc.Core (>= 1.16.0)
- Grpc.Tools (>= 1.16.0)
Used By
NuGet packages (9)
Showing the top 5 NuGet packages that depend on dotnet-etcd:
Package | Downloads |
---|---|
Etcd.Configuration
Get configuration from etcd configuration center.
|
|
etcd.Provider.Cluster.Extensions
etcd扩展,定时刷新集群节点地址
|
|
Ocelot.Provider.Etcd
Provides Ocelot extensions to use Etcd
|
|
Ocelot.Provider.Etcd.Cluster
发布
|
|
etcd.Provider.Service
etcd注册服务,方法扩展;个人提供任意使用,保留注释
|
GitHub repositories
This package is not used by any popular GitHub repositories.
Version History
Version | Downloads | Last updated |
---|---|---|
4.2.0 | 5,226 | 12/8/2020 |
4.1.1 | 29,172 | 7/12/2020 |
4.1.0-beta | 276 | 5/31/2020 |
4.0.0-beta | 126 | 5/10/2020 |
3.2.0 | 14,600 | 4/6/2020 |
3.1.1 | 2,838 | 3/21/2020 |
3.1.0 | 1,380 | 2/23/2020 |
3.0.0.1-beta | 497 | 9/6/2019 |
3.0.0 | 39,571 | 9/24/2019 |
3.0.0-beta | 2,441 | 9/6/2019 |
3.0.0-alpha | 244 | 8/11/2019 |
2.3.1 | 45,046 | 3/18/2019 |
2.3.0 | 766 | 3/9/2019 |
2.2.0 | 437 | 2/17/2019 |
2.1.1 | 408 | 2/12/2019 |
2.1.0 | 843 | 1/27/2019 |
2.0.1 | 6,487 | 12/9/2018 |
2.0.0 | 716 | 11/18/2018 |