bool IsDevelopment { get; init; }
Source
Gets whether the settings were read for the Development environment.
Builds and starts the passive, application-owned Durable external-activation host.
Call CreateBuilder(string[])
, configure a production authentication scheme and the named ActivationAuthorization
policy when outside Development, then call BuildAsync(WebApplicationBuilder, CancellationToken)
followed by StartAsync(WebApplication, CancellationToken)
. Build validates authentication before opening a database connection; startup then performs read-only schema, StoreId, and epoch checks before listening. The returned application owns the restricted data sources and OpenTelemetry provider and must be disposed by its caller. Each built host receives a fresh privacy-safe worker identity so concurrent hosts have independent heartbeat and claim ownership, including when they share one process. No worker service, migration, grant, or epoch mutation is started here.
WebApplicationBuilder CreateBuilder(string[] args)
Creates a web builder rooted at the generated settings copy with loopback-only listener defaults and DI validation.
args
A builder that the application may configure before calling BuildAsync(WebApplicationBuilder, CancellationToken)
.
ArgumentNullException
args
is null.Task<WebApplication> BuildAsync(WebApplicationBuilder builder, CancellationToken cancellationToken = default)
Validates composition, performs bounded read-only PostgreSQL startup checks, and returns an unstarted host.
builder
cancellationToken
A passive application that has not opened its listener.
ArgumentNullException
builder
is null.InvalidOperationException
TimeoutException
OperationCanceledException
cancellationToken
is canceled.
In Development this method registers the sample bearer scheme and named policy from the required DevelopmentTokenKey
configuration value. In other environments the caller must register a real application-selected scheme and a named policy that requires an authenticated user. Policy and scheme validation runs before any PostgreSQL connection is opened. Store validation is read-only; a missing or incompatible schema, configured StoreId mismatch, or epoch mismatch fails closed.
Task<WebApplication> BuildWithStartupSeamsAsync(WebApplicationBuilder builder, Func<WorkerHostSettings, WorkerDataSources> dataSourceFactory, Func<WorkerDataSources, CancellationToken, ValueTask<DurableRuntimeSchemaStatus>> schemaStatusReader, TimeSpan startupBudget, CancellationToken cancellationToken = default)
Builds through explicit startup seams for friend-assembly host contract tests.
builder
dataSourceFactory
schemaStatusReader
startupBudget
cancellationToken
A built but unstarted application when the configured observation is compatible.
This seam is internal so installed application consumers continue to use the production PostgreSQL reader.
Task StartAsync(WebApplication app, CancellationToken cancellationToken = default)
Starts the listener using the remaining portion of the same ten-second startup budget.
app
BuildAsync(WebApplicationBuilder, CancellationToken)
.cancellationToken
A task that completes when the HTTP listener is active.
ArgumentNullException
app
is null.TimeoutException
OperationCanceledException
cancellationToken
is canceled.void ValidateAuthenticationComposition(IServiceCollection services)
Validates the named authenticated policy and every scheme it can select before database access.
services
This intentional short-lived provider resolves only framework auth/authorization metadata. The registered application host is built once after validation; no PostgreSQL source is present in this validation provider.
void ConfigureAuthentication(WebApplicationBuilder builder, string? developmentToken)
Maps only the supported Development auth defaults and closed authorization policy.
builder
developmentToken
void ValidateSchemaIdentity(DurableRuntimeSchemaStatus status, WorkerHostSettings settings)
Checks the read-only schema observation against both explicitly configured process identities.
status
settings
ValueTask DisposeFailedBuildAsync(WebApplication? app, WorkerDataSources? dataSources)
Attempts every resource disposal after an unsuccessful build.
app
dataSources
Contains validated runtime settings captured before resources or listeners are created.
DispatcherConnectionString
RuntimeConnectionString
StoreId
RuntimeEpoch
RuntimeRole
MaximumPoolSize
ConnectionTimeoutSeconds
CommandTimeoutSeconds
Activation
DevelopmentToken
OtlpEndpoint
Diagnostic formatting includes only StoreId and runtime epoch. Individual properties still contain credentials or application configuration and must not be logged directly.
bool PrintMembers(System.Text.StringBuilder builder)
Restricts record diagnostic formatting to the two non-secret provisioned identities.
builder
True because both identity members were appended.
WorkerHostSettings Read(IConfiguration configuration, IWebHostEnvironment environment)
Reads all non-secret settings and rejects malformed or out-of-range values without echoing them.
configuration
environment
Immutable settings snapshot.
InvalidOperationException
string ParseRuntimeRole(string connectionString)
Reads a required bounded identity from a connection string without logging the connection text.
connectionString
The nonblank login role.
string RequireText(IConfiguration configuration, string key)
Reads a nonblank configuration value and reports only its key on failure.
configuration
key
The configured value.
Guid RequireGuid(IConfiguration configuration, string key)
Reads a nonempty Guid setting.
configuration
key
The parsed identity.
int ReadInteger(IConfiguration configuration, string key, int defaultValue, int minimum, int maximum)
Reads an invariant integer and enforces its inclusive range.
configuration
key
defaultValue
minimum
maximum
The validated value.
bool IsDevelopment { get; init; }
Source
Gets whether the settings were read for the Development environment.
Captures the host-only numeric contracts for a payload-free activation and its ingress body phase.
PumpMaximumItems
PumpDiscoveryBudget
RequestBudget
BodyReadBudget
Owns one shared monotonic deadline for configuration, validation, and listener startup.
StartedAtTimestamp
Budget
TimeSpan GetRemaining()
Gets the remaining startup time without consulting wall-clock time.
Zero after the fixed budget expires.
void ThrowIfExpired()
Throws a stable timeout when synchronous composition exhausts the shared budget.
Owns distinct dispatcher and runtime sources and disposes both even if one disposal fails.
Dispatcher
Runtime
RuntimeRole
WorkerDataSources Create(WorkerHostSettings settings)
Creates distinct bounded data sources only after authentication composition is validated.
settings
Owned source pair.
ValueTask DisposeAsync()
Disposes both restricted sources and preserves every disposal failure.
NpgsqlDataSource CreateDataSource(string connectionString, int maximumPoolSize, int connectionTimeoutSeconds, int commandTimeoutSeconds, string settingName)
Applies the documented bounded pool and timeout defaults without changing credentials or role identity.
connectionString
maximumPoolSize
connectionTimeoutSeconds
commandTimeoutSeconds
settingName
A newly constructed, unopened data source.