![]() |
VOOZH | about |
dotnet add package dotnet-etcd --version 8.1.0
NuGet\Install-Package dotnet-etcd -Version 8.1.0
<PackageReference Include="dotnet-etcd" Version="8.1.0" />
<PackageVersion Include="dotnet-etcd" Version="8.1.0" />Directory.Packages.props
<PackageReference Include="dotnet-etcd" />Project file
paket add dotnet-etcd --version 8.1.0
#r "nuget: dotnet-etcd, 8.1.0"
#:package dotnet-etcd@8.1.0
#addin nuget:?package=dotnet-etcd&version=8.1.0Install as a Cake Addin
#tool nuget:?package=dotnet-etcd&version=8.1.0Install as a Cake Tool
A C# .NET (dotnet) GRPC client for etcd v3+
👁 Build Status
👁 Nuget Version Info
👁 Nuget Download Info
👁 Code Coverage
For older .NET versions:
Nuget package is published on nuget.org and can be installed in the following ways:
Install-Package dotnet-etcd
dotnet add package dotnet-etcd
paket add dotnet-etcd
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
For comprehensive documentation of all operations and method overloads, please see the .
The documentation is organized into the following sections:
The documentation includes detailed API references with all method overloads, parameters, and return types, as well as examples for common use cases.
Add using statement at the top of your class file:
using dotnet_etcd;
// Basic initialization with a single endpoint
EtcdClient client = new EtcdClient("localhost:2379");
// Multiple endpoints
EtcdClient client = new EtcdClient("https://localhost:23790,https://localhost:23791,https://localhost:23792");
// Insecure connection (HTTP)
EtcdClient client = new EtcdClient("http://localhost:23790", configureChannelOptions: (options =>
{
options.Credentials = ChannelCredentials.Insecure;
}));
For more advanced initialization options, see the .
// Automatic authentication with constructor
var client = new EtcdClient("localhost:2379", "username", "password");
// All requests automatically authenticated
client.Put("foo/bar", "barfoo");
client.Get("foo/bar");
// Or set credentials after creation
var client = new EtcdClient("localhost:2379");
client.SetCredentials("username", "password");
For more authentication options, see the .
Built-in support for Microsoft.Extensions.DependencyInjection with extension methods for easy configuration:
services.AddEtcdClient(options => {
options.ConnectionString = "localhost:2379";
options.UseInsecureChannel = true;
});
dotnet-etcd includes an automatic retry mechanism for handling transient failures when communicating with etcd clusters. By default, the client is configured with a retry policy that:
This functionality is enabled by default and requires no additional configuration.
Operations can be canceled using a CancellationToken. By default, the client throws OperationCanceledException when a request is canceled.
CancellationTokenSource cts = new CancellationTokenSource();
try {
cts.Cancel();
var response = client.Status(new StatusRequest(), cancellationToken: cts.Token);
} catch (OperationCanceledException) {
Console.WriteLine("Operation was canceled.");
}
For legacy cancellation behavior with RpcException, see the .
Most errors from the etcd client are thrown as RpcException with specific status codes that can be handled
appropriately:
try {
var response = client.Get("non-existent-key");
} catch (RpcException ex) {
switch (ex.StatusCode) {
case StatusCode.NotFound:
Console.WriteLine("Key not found");
break;
case StatusCode.Unavailable:
Console.WriteLine("Server unavailable");
break;
// Handle other status codes
}
}
The EtcdClient implements IDisposable and should be properly disposed when no longer needed:
using (var client = new EtcdClient("https://localhost:2379")) {
var response = client.Get("my-key");
// ...
}
For more details on proper client disposal, see the .
We welcome contributions to help improve dotnet-etcd! Please see the CONTRIBUTING.md file for guidelines on how to contribute.
For bug reports, feature requests, or questions, please create an issue on GitHub.
The project includes both unit tests and integration tests. Unit tests can be run without any external dependencies, while integration tests require a running etcd cluster.
The dotnet-etcd.Tests directory includes scripts to easily set up either a single-node or a 3-node etcd cluster using
Docker:
cd dotnet-etcd.Tests
# Start a single-node cluster
./start-etcd.sh
# Or start a 3-node cluster
./start-etcd.sh 3nodes
# Run the tests
dotnet test
# Stop the cluster when done
./stop-etcd.sh
For convenience, you can also use the script that handles the entire process:
cd dotnet-etcd.Tests
# Run integration tests with a single-node cluster
./run-integration-tests.sh
# Or with a 3-node cluster
./run-integration-tests.sh 3nodes
See the for more details on running tests.
To run only the unit tests (which don't require a running etcd server):
dotnet test dotnet-etcd.Tests/dotnet-etcd.Tests.csproj --filter "FullyQualifiedName~Unit"
To run integration tests, you need a running etcd server. The integration tests will connect to etcd at localhost:2379
by default.
dotnet test dotnet-etcd.Tests/dotnet-etcd.Tests.csproj --filter "FullyQualifiedName~Integration"
To run all tests:
dotnet test dotnet-etcd.Tests/dotnet-etcd.Tests.csproj
To run tests with code coverage and generate a report:
dotnet tool install -g dotnet-reportgenerator-globaltool
./run-unit-tests-with-coverage.sh
./dotnet-etcd.Tests/TestResults/CoverageReport/index.htmlThis project is licensed under the MIT License - see the LICENSE file for details.
We have comprehensive test coverage for dotnet-etcd, including both unit tests and integration tests.
For detailed information about running tests and generating code coverage reports, see the file.
# Run unit tests only
dotnet test dotnet-etcd.Tests/dotnet-etcd.Tests.csproj --filter "Category=Unit"
# Run integration tests (requires running etcd server)
dotnet test dotnet-etcd.Tests/dotnet-etcd.Tests.csproj --filter "Category=Integration"
# Run all tests
dotnet test dotnet-etcd.Tests/dotnet-etcd.Tests.csproj
We use GitHub Actions to automatically generate code coverage reports for the main branch. You can view the latest code coverage report on the GitHub Pages site.
To generate a code coverage report locally:
# Install the required tools
dotnet tool install --global dotnet-reportgenerator-globaltool
# Run tests with coverage
dotnet test dotnet-etcd.Tests/dotnet-etcd.Tests.csproj --collect:"XPlat Code Coverage"
# Generate HTML report
reportgenerator -reports:"**/coverage.cobertura.xml" -targetdir:"coveragereport" -reporttypes:Html
# Open the report
open coveragereport/index.html # On macOS
# or
start coveragereport/index.html # On Windows
For more details, see the file.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 5 NuGet packages that depend on dotnet-etcd:
| Package | Downloads |
|---|---|
|
NetCorePal.Extensions.Snowflake.Etcd
NetCorePal Cloud Framework |
|
|
Etcd.Microsoft.Extensions.Configuration
Etcd based configuration provider for Microsoft.Extensions.Configuration |
|
|
cm-catalog-etcd
A CM Catalog implementation using etcd. |
|
|
Etcd.Configuration
Get configuration from etcd configuration center. |
|
|
etcd.Provider.Cluster.Extensions
etcd客户端扩展,集群客户端刷新 |
Showing the top 2 popular GitHub repositories that depend on dotnet-etcd:
| Repository | Stars |
|---|---|
|
asynkron/protoactor-dotnet
Proto Actor - Ultra fast distributed actors for Go, C# and Java/Kotlin
|
|
|
netcorepal/netcorepal-cloud-framework
一个基于ASP.NET Core实现的整洁领域驱动设计落地战术框架。 A tactical framework for Clean Domain-Driven Design based on ASP.NET Core.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 8.1.0 | 42,376 | 12/21/2025 |
| 8.0.1 | 65,586 | 5/10/2025 |
| 8.0.0 | 5,824 | 3/22/2025 |
| 7.2.0 | 145,000 | 10/19/2024 |
| 7.1.1 | 32,515 | 8/4/2024 |
| 7.1.0 | 926 | 7/30/2024 |
| 7.0.0 | 3,269 | 7/14/2024 |
| 7.0.0-beta | 28,320 | 1/7/2024 |
| 6.2.0-beta | 26,012 | 12/7/2022 |
| 6.0.1 | 338,554 | 11/9/2022 |
| 6.0.0-beta.0 | 3,560 | 9/27/2022 |
| 5.2.1 | 188,227 | 7/16/2022 |
| 5.2.0 | 123,273 | 3/2/2022 |
| 5.1.0 | 79,083 | 10/19/2021 |
| 5.0.2 | 37,730 | 9/6/2021 |
| 5.0.2-alpha | 1,014 | 8/22/2021 |
| 5.0.0-alpha | 970 | 8/9/2021 |
| 4.2.0 | 487,379 | 12/8/2020 |
| 4.1.1 | 95,086 | 7/12/2020 |