Table of Contents

Class Component

Namespace
Quilt4Net.Toolkit.Features.Health
Assembly
Quilt4Net.Toolkit.dll

Component for availability checking.

public record Component : IEquatable<Component>
Inheritance
Component
Implements
Inherited Members

Properties

CacheDuration

Optional. How long a successful-or-failed CheckResult is cached (keyed by Name) before the check is run again. Repeated polls within this window reuse the cached result and concurrent runs are coalesced into a single check — so sustained polling of a deep endpoint runs each check at most once per window instead of on every request. Set to null (default) or Zero to disable caching and run every time. Relies on Name being unique.

public TimeSpan? CacheDuration { get; init; }

Property Value

TimeSpan?

CheckAsync

Method that performs the check for the component.

public required Func<IServiceProvider, Task<CheckResult>> CheckAsync { get; init; }

Property Value

Func<IServiceProvider, Task<CheckResult>>

CheckWithCancellationAsync

Optional. Cancellation-aware check. When set it is used instead of CheckAsync and receives a token that is cancelled when Timeout elapses (or the request is aborted). Prefer this over CheckAsync when the check does cancellable I/O: on timeout the check can actually abort and free its resources (e.g. an HTTP connection), rather than being left running while only the wait is abandoned. Default is null (use CheckAsync).

public Func<IServiceProvider, CancellationToken, Task<CheckResult>> CheckWithCancellationAsync { get; init; }

Property Value

Func<IServiceProvider, CancellationToken, Task<CheckResult>>

Essential

Non-essential component will be considered Degraded if they fail. Essential components will be considered to Unhealthy/Unready that will result in 503 response. Default is true.

public bool Essential { get; init; }

Property Value

bool

Name

Name of the component. This name needs to be unique.

public required string Name { get; init; }

Property Value

string

Timeout

Optional. Bounds how long the check may run. On timeout the component is reported as a failed CheckResult (mapped to Degraded/Unhealthy per Essential) with a clear message, instead of hanging and holding resources. With CheckWithCancellationAsync the check is actually cancelled; with a plain CheckAsync the wait is bounded (the check itself cannot be aborted). Set to null (default) or Zero for no timeout.

public TimeSpan? Timeout { get; init; }

Property Value

TimeSpan?