Interface IStartupPrerequisiteValidator
- Namespace
- Microsoft.Extensions.DependencyInjection
- Assembly
- Excalibur.Dispatch.Abstractions.dll
A fail-fast wiring check that must run before the first message is handled, and that can run against a built container alone — without starting a host.
public interface IStartupPrerequisiteValidator
- Extension Methods
Remarks
Prerequisite validators answer one question: did the consumer wire everything this feature requires? A missing store provider, an encryption feature switched on with no key provider, an aggregate registered with no serializable event type. They inspect the container and throw with actionable guidance; they perform no I/O and have no side effects, so running one twice is indistinguishable from running it once.
Implementations are normally also registered as an IHostedService, which is what places the check
in a host's startup pipeline. Implementing this interface as well is what lets the same check run for a
consumer who builds an IServiceProvider and never starts a host — see
ValidateStartupGates(IServiceProvider). Register
both, so both topologies fail fast:
services.TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService, MyPrerequisiteValidator>());
services.TryAddEnumerable(ServiceDescriptor.Singleton<IStartupPrerequisiteValidator, MyPrerequisiteValidator>());
A check that needs I/O — probing a remote mount, reading a physical schema — is deliberately outside this
contract, because it cannot be performed from a synchronous method without blocking. Such a check stays an
IHostedService and carries its own fail-closed floor on the path it protects.
Methods
Validate()
Verifies the prerequisites this validator guards, throwing when they are not satisfied.
void Validate()
Remarks
Must be free of I/O and side effects, and safe to call more than once on the same container.
Exceptions
- InvalidOperationException
A required prerequisite is missing or misconfigured.