Class ConsulCatalogueProvider

Namespace
Kuestenlogik.Bowire.Sources
Assembly
Kuestenlogik.Bowire.dll

Queries a HashiCorp Consul agent's v1 catalogue API (#136 Phase C) and materialises each registered service into a BowireCatalogueEntry. Bound to Bowire:Discovery:Catalogue:Consul via BowireConsulCatalogueOptions.

public sealed class ConsulCatalogueProvider : IBowireCatalogueProvider
Inheritance
ConsulCatalogueProvider
Implements
Inherited Members

Remarks

Two API calls per refresh:

  1. GET /v1/catalog/services — returns a map of { "name": ["tag", ...] }. We use the tag list to skip services that don't match the optional Tag filter up-front.
  2. GET /v1/catalog/service/{name} for each matching service. The response carries ServiceAddress (or the fallback Address) + ServicePort which we assemble into the entry URL using the configured Scheme.

Consul's catalogue carries only network coordinates — it doesn't tell us which Bowire protocol plugin (rest / grpc / signalr / ...) each service speaks. We surface the Consul tags as the entry's tags so operators can filter in the workbench; the protocol probe fan-out handles plugin selection at invocation time, same as for hand-entered URLs.

One HttpClient per fetch — the call volume is tiny (one catalogue refresh every few minutes) and the per-fetch instance keeps the timeout / handler resets simple. Hosts with much larger registries should run a pre-aggregation relay and point Bowire at it via the cheaper http provider.

Constructors

ConsulCatalogueProvider()

Parameterless ctor for the assembly-scan discovery path. Uses environment-variable-driven defaults so the registry can instantiate the provider before AddBowireCatalogue has wired explicit options.

public ConsulCatalogueProvider()

Properties

Id

Stable id used to select this provider in config (e.g. "local", "http", "consul", "kubernetes", "agent"). Compared case-insensitively against the configured provider key.

public string Id { get; }

Property Value

string

Name

Human-readable provider name for the Settings → Sources tab and startup logs (e.g. "Local file", "HTTP endpoint", "Consul").

public string Name { get; }

Property Value

string

Methods

FetchAsync(CancellationToken)

Fetch the current catalogue snapshot. Called on a configurable refresh interval (default 5 minutes; see RefreshInterval) and on a manual trigger from the workbench UI.

public Task<IReadOnlyList<BowireCatalogueEntry>> FetchAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Cancellation token — refresh cycles are bounded by the configured interval, so providers should respect it to avoid piling up overlapping fetches when an upstream is slow.

Returns

Task<IReadOnlyList<BowireCatalogueEntry>>

The list of catalogue entries currently visible to this provider. Empty list is fine (means "no entries"); throw to signal a hard fetch failure — the registry catches and surfaces it as a problem-details response on GET /api/catalogue/entries.