Table of Contents

Class GlobalStreamProjectionHost<TState>

Namespace
Excalibur.EventSourcing.Projections
Assembly
Excalibur.EventSourcing.dll

Background service that hosts a IGlobalStreamProjection<TState>, continuously reading from the global event stream via IGlobalStreamQuery and applying events to the projection state.

public sealed class GlobalStreamProjectionHost<TState> : BackgroundService, IHostedService, IDisposable where TState : class, new()

Type Parameters

TState

The projection state type.

Inheritance
GlobalStreamProjectionHost<TState>
Implements
Inherited Members

Remarks

This host manages the lifecycle of a global stream projection, including:

Events from the event store are StoredEvent records and must be deserialized to IDomainEvent before applying to the projection. This host uses IEventSerializer for deserialization.

Constructors

GlobalStreamProjectionHost(IServiceScopeFactory, IEventSerializer, IOptions<GlobalStreamProjectionOptions>, ILogger<GlobalStreamProjectionHost<TState>>, IServiceProvider)

Initializes a new instance of the GlobalStreamProjectionHost<TState> class.

public GlobalStreamProjectionHost(IServiceScopeFactory scopeFactory, IEventSerializer eventSerializer, IOptions<GlobalStreamProjectionOptions> options, ILogger<GlobalStreamProjectionHost<TState>> logger, IServiceProvider serviceProvider)

Parameters

scopeFactory IServiceScopeFactory

The scope factory used to resolve the (typically scoped) global-stream query, projection, checkpoint store, and optional cursor-map store from a fresh scope per polling cycle (avoids a captive dependency in this singleton host).

eventSerializer IEventSerializer

The event serializer for deserializing stored events.

options IOptions<GlobalStreamProjectionOptions>

The projection host options.

logger ILogger<GlobalStreamProjectionHost<TState>>

The logger.

serviceProvider IServiceProvider

The service provider for resolving internal observability services.

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

stoppingToken CancellationToken

Triggered when StopAsync(CancellationToken) is called.

Returns

Task

A Task that represents the long running operations.

Remarks

See Worker Services in .NET for implementation guidelines.