Table of Contents

Interface IPersistenceProviderHealth

Namespace
Excalibur.Data.Persistence
Assembly
Excalibur.Data.Abstractions.dll

Provides health and diagnostics capabilities for persistence providers. Obtain via GetService(Type) with typeof(IPersistenceProviderHealth).

public interface IPersistenceProviderHealth

Remarks

This interface follows the ISP pattern — consumers that only need to execute data requests use IPersistenceProvider directly. Health checks and monitoring tools use this sub-interface.

Reference: Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck — single method; this interface adds provider-specific diagnostics beyond simple pass/fail.

Properties

IsAvailable

Gets a value indicating whether the provider is ready to serve requests.

bool IsAvailable { get; }

Property Value

bool

true while the provider is ready to serve and has not been disposed; otherwise, false.

Remarks

Readiness may be established either at construction — when the provider is handed an already connected dependency, such as a client it does not own — or by InitializeAsync for providers that build their own connection from configuration. Both are supported; which one applies is a property of the constructor you chose, not of the interface.

Implementations must report false once disposed, and may report false while otherwise ready if the underlying connection has dropped. This is a cheap, non-blocking status flag rather than a probe: reading it must not perform I/O.

Methods

GetMetricsAsync(CancellationToken)

Gets provider-specific health and performance metrics.

Task<IDictionary<string, object>> GetMetricsAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IDictionary<string, object>>

A dictionary of metric names and values.

Remarks

The returned dictionary MUST contain two identifying entries, and they carry different dimensions:

  • "Provider" is the engine identity — a fixed literal, constant per implementation and identical for every instance of it (for example "SqlServer" for every SQL Server instance). It MUST NOT vary with configuration, and in particular MUST NOT be set from Name, which is the instance dimension and would make the engine unreadable.
  • "Name" is the instance identity — the value of Name, which distinguishes two separately configured instances of the same engine.

Together they let a consumer aggregating across a mixed deployment group by engine and still attribute a reading to the instance that produced it. Keys are compared with an ordinal comparer, so the casing is part of the contract -- "provider" is a different key and does not satisfy it. Every other key is provider-specific; the convention is PascalCase. The conformance suite verifies the required entries.

TestConnectionAsync(CancellationToken)

Tests the connection to the persistence provider.

Task<bool> TestConnectionAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The cancellation token.

Returns

Task<bool>

true if the connection is successful; otherwise, false.