Skip to content

Fast.Consul ​

Public members, parameters, returns, and exceptions

Reference source version 3.5.16; targets: net8.0;net9.0;net10.0.

When upgrading code that uses platform flags, see the Runtime H5 migration guide and the dependency history.

Contract and constraints ​

Service registration, health checks and KV access. AddFastConsul() defaults to ConsulSettings and returns the service collection. Null services/configuration throw ArgumentNullException; an empty section name throws ArgumentException. Starting the host can register a service with Consul. Defaults are Enable=true, Address=http://127.0.0.1:8500, HealthCheck=/healthCheck, deregistration after 60 seconds of critical health, interval 10 seconds and timeout 5 seconds. Durations must be positive. ServiceAddress falls back to the listening address; configure a reachable address behind proxies. IKeyValueService is transient. GetKeyValue returns decoded text or deserializes T; missing keys throw KeyNotFoundException, invalid Base64 throws FormatException, and JSON failures propagate. EditKeyValue performs a remote write and returns Consul confirmation. There is no cancellation-token overload.

Installation and examples ​

Install the package ​

bash
dotnet add package Fast.Consul

Example 1 ​

csharp
using Fast.Consul;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Builder;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddFastConsul(builder.Configuration, "ConsulSettings");

var app = builder.Build();
app.MapGet("/healthCheck", () => "healthy");
app.Run();

Example 2 ​

csharp
using Fast.Consul;

public sealed class FeatureSettings
{
    public bool EnablePreview { get; set; }
}

public sealed class FeatureReader(IKeyValueService values)
{
    public Task<FeatureSettings> ReadAsync() =>
        values.GetKeyValue<FeatureSettings>("sample/features", "dc1");
}

Web-host examples belong in a consumer project using Microsoft.NET.Sdk.Web and a supported .NET target. IaaS examples can be used in an ordinary class library. Registration precedes builder.Build(); configure middleware and endpoints before app.Run(). Samples retain their original code and comments. No host, external service, database operation or client generator was run, and these snippets have not been compiled in this update.

Source reference ​

Dependency alignment on 2026-11-02 ​

2026-11-02 dependency alignment: this package increments from 3.5.15 to 3.5.16, updating its dependency to Fast.Runtime 3.5.37. This module's implementation and public declarations are unchanged. Runtime adds mobile H5 and shifts Android and subsequent flags; migrate numeric protocols/masks, rebuild consumers and regenerate client enums. See the Runtime H5 migration guide.

2026-10-24 versions and dependencies ​

On 2026-10-24, this package increments from 3.5.12 to 3.5.13, with dependencies updated to Fast.Runtime 3.5.34. This module's own implementation and public declarations are unchanged.

Consumers using AppEnvironmentEnum must migrate numeric values and rebuild according to the Runtime HarmonyOS migration guide. This batch reviewed source and effective MSBuild package metadata only. Tests were skipped as requested; no restore, build, pack or consumer runtime validation was performed.