Skip to content

Fast.Consul public API

Targets: net8.0;net9.0;net10.0. This is a declaration and XML-comment reference. See the module guide for usage and constraints.

Source commit: 43554c07f6c216f80b509bd535c0a5b66ae7f2e8. Maintained through scripts/export-dotnet-api.ps1 -Language en; ordinary site builds consume this file directly.

Fast.Consul.ConsulServiceCollectionExtensions

Source · Targets: net8.0, net9.0, net10.0

csharp
public static class ConsulServiceCollectionExtensions

Consul service registration extensions

Fast.Consul.ConsulServiceCollectionExtensions.AddFastConsul

Source · Targets: net8.0, net9.0, net10.0

csharp
public static IServiceCollection AddFastConsul(this IServiceCollection services, IConfiguration configuration,
        string section = "ConsulSettings")

Registers Consul service discovery, health checks and key-value services

  • Parameter services: Service collection
  • Parameter configuration: Application configuration
  • Parameter section: Configuration section name
  • Returns: Returns the current service collection for chaining

Fast.Consul.IKeyValueService

Source · Targets: net8.0, net9.0, net10.0

csharp
public interface IKeyValueService

Key/value service

Fast.Consul.IKeyValueService.GetKeyValue

Source · Targets: net8.0, net9.0, net10.0

csharp
Task<T> GetKeyValue<T>(string settingPath, string dcName);

Reads Consul configuration

  • Throws ArgumentException: settingPath or dcName is empty
  • Throws KeyNotFoundException: The specified configuration path does not exist in Consul
  • Throws FormatException: The configuration value returned by Consul is not valid Base64 text
  • Throws System.Text.Json.JsonException: The configuration content cannot be deserialized as T
  • Parameter settingPath: Key path containing the configuration in Consul
  • Parameter dcName: Consul datacenter name
  • Type parameter T: Type to deserialize the configuration value into
  • Returns: A task whose result is the retrieved Consul configuration

Fast.Consul.IKeyValueService.GetKeyValue

Source · Targets: net8.0, net9.0, net10.0

csharp
Task<string> GetKeyValue(string settingPath, string dcName);

Reads Consul configuration

  • Throws ArgumentException: settingPath or dcName is empty
  • Throws KeyNotFoundException: The specified configuration path does not exist in Consul
  • Throws FormatException: The configuration value returned by Consul is not valid Base64 text
  • Parameter settingPath: Key path containing the configuration in Consul
  • Parameter dcName: Consul datacenter name
  • Returns: A task whose result is the retrieved Consul configuration

Fast.Consul.IKeyValueService.EditKeyValue

Source · Targets: net8.0, net9.0, net10.0

csharp
Task<bool> EditKeyValue(string settingPath, string dcName, string data);

Edits Consul configuration

  • Throws ArgumentException: settingPath or dcName is empty
  • Parameter settingPath: Key path containing the configuration in Consul
  • Parameter dcName: Consul datacenter name
  • Parameter data: Configuration text to write to Consul
  • Returns: Returns true when Consul confirms the write; otherwise false

Fast.Consul.KeyValueService

Source · Targets: net8.0, net9.0, net10.0

csharp
public class KeyValueService : IKeyValueService

Documentation is inherited from an interface or base class; consult that declaration.

Fast.Consul.KeyValueService.GetKeyValue

Source · Targets: net8.0, net9.0, net10.0

csharp
public async Task<T> GetKeyValue<T>(string settingPath, string dcName)

Documentation is inherited from an interface or base class; consult that declaration.

Fast.Consul.KeyValueService.GetKeyValue

Source · Targets: net8.0, net9.0, net10.0

csharp
public async Task<string> GetKeyValue(string settingPath, string dcName)

Documentation is inherited from an interface or base class; consult that declaration.

Fast.Consul.KeyValueService.EditKeyValue

Source · Targets: net8.0, net9.0, net10.0

csharp
public async Task<bool> EditKeyValue(string settingPath, string dcName, string data)

Documentation is inherited from an interface or base class; consult that declaration.

Fast.Consul.ConsulSettingsOptions

Source · Targets: net8.0, net9.0, net10.0

csharp
public sealed class ConsulSettingsOptions : IPostConfigure

Consul configuration options

Fast.Consul.ConsulSettingsOptions.Enable

Source · Targets: net8.0, net9.0, net10.0

csharp
[Required]
    public bool? Enable { get; set; }

Whether Consul is enabled

Fast.Consul.ConsulSettingsOptions.Address

Source · Targets: net8.0, net9.0, net10.0

csharp
[Required]
    public string Address { get; set; }

Consul client address

Fast.Consul.ConsulSettingsOptions.ServiceAddress

Source · Targets: net8.0, net9.0, net10.0

csharp
public string ServiceAddress { get; set; }

Advertised service address; uses the actual server listening address when empty

Remarks: In containers or behind reverse proxies, explicitly configure an absolute address reachable by Consul.

Fast.Consul.ConsulSettingsOptions.HealthCheck

Source · Targets: net8.0, net9.0, net10.0

csharp
[Required]
    public string HealthCheck { get; set; }

Consul health check address

Fast.Consul.ConsulSettingsOptions.DeregisterCriticalServiceAfter

Source · Targets: net8.0, net9.0, net10.0

csharp
public int? DeregisterCriticalServiceAfter { get; set; }

Delay after Consul service startup before registration, in seconds

Fast.Consul.ConsulSettingsOptions.HealthCheckInterval

Source · Targets: net8.0, net9.0, net10.0

csharp
public int? HealthCheckInterval { get; set; }

Consul health check interval in seconds

Fast.Consul.ConsulSettingsOptions.HealthCheckTimeout

Source · Targets: net8.0, net9.0, net10.0

csharp
public int? HealthCheckTimeout { get; set; }

Consul health check timeout in seconds

Fast.Consul.ConsulSettingsOptions.PostConfigure

Source · Targets: net8.0, net9.0, net10.0

csharp
public void PostConfigure()

Documentation is inherited from an interface or base class; consult that declaration.