Class GovernanceOutboxDrainHostedService
- Namespace
- AsiBackbone.AspNetCore.Outbox
- Assembly
- AsiBackbone.AspNetCore.dll
Runs the provider-neutral outbox drain from an ASP.NET Core or generic-host background worker.
public sealed class GovernanceOutboxDrainHostedService : BackgroundService, IHostedService, IDisposable
- Inheritance
-
GovernanceOutboxDrainHostedService
- Implements
- Inherited Members
Remarks
Hosting remains outside Core. Startup validates the scoped drain dependency graph and fails when the store or emitter
cannot be resolved. Each drain cycle then resolves the drain through a new scoped service provider so durable providers
that depend on scoped infrastructure, such as a host-owned EF Core DbContext, remain safe to use. Runtime changes
to Enabled pause or resume new drain cycles without
terminating the hosted service.
Constructors
GovernanceOutboxDrainHostedService(IServiceScopeFactory, IOptionsMonitor<GovernanceOutboxDrainWorkerOptions>, ILogger<GovernanceOutboxDrainHostedService>, TimeProvider?)
Runs the provider-neutral outbox drain from an ASP.NET Core or generic-host background worker.
public GovernanceOutboxDrainHostedService(IServiceScopeFactory scopeFactory, IOptionsMonitor<GovernanceOutboxDrainWorkerOptions> optionsMonitor, ILogger<GovernanceOutboxDrainHostedService> logger, TimeProvider? timeProvider = null)
Parameters
scopeFactoryIServiceScopeFactoryThe factory used to create a scope for each drain cycle.
optionsMonitorIOptionsMonitor<GovernanceOutboxDrainWorkerOptions>The monitored worker options.
loggerILogger<GovernanceOutboxDrainHostedService>The worker logger.
timeProviderTimeProviderThe clock used for drain timestamps unless RetryClock has been assigned a custom delegate. Defaults to System; dependency injection supplies a registered TimeProvider.
Remarks
Hosting remains outside Core. Startup validates the scoped drain dependency graph and fails when the store or emitter
cannot be resolved. Each drain cycle then resolves the drain through a new scoped service provider so durable providers
that depend on scoped infrastructure, such as a host-owned EF Core DbContext, remain safe to use. Runtime changes
to Enabled pause or resume new drain cycles without
terminating the hosted service.
Methods
ExecuteAsync(CancellationToken)
This method is called when the IHostedService starts. The implementation should return a task that represents the lifetime of the long running operation(s) being performed.
protected override Task ExecuteAsync(CancellationToken stoppingToken)
Parameters
stoppingTokenCancellationTokenTriggered when StopAsync(CancellationToken) is called.
Returns
Remarks
See Worker Services in .NET for implementation guidelines.
StartAsync(CancellationToken)
Triggered when the application host is ready to start the service.
public override Task StartAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenIndicates that the start process has been aborted.
Returns
StopAsync(CancellationToken)
Triggered when the application host is performing a graceful shutdown.
public override Task StopAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenIndicates that the shutdown process should no longer be graceful.