Class ProtoReadinessExtensions

Namespace
ProtoTest.Core
Assembly
ProtoTest.Core.dll

Registers readiness probes the host awaits before the first test.

public static class ProtoReadinessExtensions
Inheritance
ProtoReadinessExtensions
Inherited Members

Methods

AddHttpReadiness(IProtoHostBuilder, string, string, Func<HttpResponseMessage, bool>?, TimeSpan?)

Awaits the address an application is published at: reads ProtoTest:Applications:{applicationName}:BaseUrl (or the value a started piece published under the same key) and probes it at run start. An application running in-process has no network address to probe and needs no wait, so the probe is skipped and says so in the trace.

public static IProtoHostBuilder AddHttpReadiness(this IProtoHostBuilder builder, string applicationName, string path = "/", Func<HttpResponseMessage, bool>? ready = null, TimeSpan? timeout = null)

Parameters

builder IProtoHostBuilder

The IProtoHostBuilder instance.

applicationName string

The application name, as registered with AddApplication.

path string

The path to request; defaults to /.

ready Func<HttpResponseMessage, bool>

Optional acceptance check; by default any HTTP response counts as ready.

timeout TimeSpan?

Overrides Timeout for this probe.

Returns

IProtoHostBuilder

Remarks

Register the probe after the piece that publishes the address: probes are awaited at their registration position, so a probe registered first resolves nothing. It does not claim the application runs in-process; it records readiness.skipped naming its position and the later publisher. An application whose address is only ever configured can be probed anywhere.

AddReadinessProbe(IProtoHostBuilder, string, Func<CancellationToken, ValueTask<bool>>, TimeSpan?)

Registers a readiness check the host awaits at run start, in registration order - register it after the piece it waits for. Use Tcp(string, int) and Http(Uri, Func<HttpResponseMessage, bool>?, TimeSpan?, Action<string>?) for the common cases, or a delegate for anything else.

public static IProtoHostBuilder AddReadinessProbe(this IProtoHostBuilder builder, string name, Func<CancellationToken, ValueTask<bool>> probe, TimeSpan? timeout = null)

Parameters

builder IProtoHostBuilder

The IProtoHostBuilder instance.

name string

The probe's name in the trace and in a timeout failure.

probe Func<CancellationToken, ValueTask<bool>>

The check; polled until it returns true or the timeout expires.

timeout TimeSpan?

Overrides Timeout for this probe.

Returns

IProtoHostBuilder

ConfigureReadiness(IProtoHostBuilder, Action<ProtoReadinessOptions>)

Changes how long the host waits for probes and how often it asks. Can be called before or after the probes are registered; later values still apply. One instance governs the host's probes and every container the run starts; the section ProtoTest:Readiness binds over the code values when the host is built.

public static IProtoHostBuilder ConfigureReadiness(this IProtoHostBuilder builder, Action<ProtoReadinessOptions> configure)

Parameters

builder IProtoHostBuilder
configure Action<ProtoReadinessOptions>

Returns

IProtoHostBuilder