Class ElasticSearchProjectionsEventSourcingBuilderExtensions
- Namespace
- Microsoft.Extensions.DependencyInjection
- Assembly
- Excalibur.Data.ElasticSearch.dll
Extension methods bridging ElasticSearch projection registration onto
IEventSourcingBuilder so consumers can configure projection
stores inside a single AddExcalibur(excalibur => excalibur.AddEventSourcing(es => ...))
composition root.
public static class ElasticSearchProjectionsEventSourcingBuilderExtensions
- Inheritance
-
ElasticSearchProjectionsEventSourcingBuilderExtensions
- Inherited Members
Methods
AddElasticSearchProjectionStore<TProjection>(IEventSourcingBuilder, IConfiguration, Action<ElasticSearchProjectionStoreOptions>?)
Registers one ElasticSearch projection store, taking its cluster from a configuration section.
[RequiresUnreferencedCode("Binds configuration to the options type reflectively; configure the store in code for trimming and AOT.")]
[RequiresDynamicCode("Binds configuration to the options type reflectively; configure the store in code for trimming and AOT.")]
public static IEventSourcingBuilder AddElasticSearchProjectionStore<TProjection>(this IEventSourcingBuilder builder, IConfiguration section, Action<ElasticSearchProjectionStoreOptions>? configureOptions = null) where TProjection : class
Parameters
builderIEventSourcingBuilderThe event-sourcing builder.
sectionIConfigurationThe configuration section describing the cluster.
configureOptionsAction<ElasticSearchProjectionStoreOptions>Optional code configuration, applied after the section so it wins.
Returns
- IEventSourcingBuilder
The same builder for fluent chaining.
Type Parameters
TProjectionThe projection type to store.
AddElasticSearchProjectionStore<TProjection>(IEventSourcingBuilder, Action<ElasticSearchProjectionStoreOptions>)
Registers a single ElasticSearch projection store for the specified projection type.
public static IEventSourcingBuilder AddElasticSearchProjectionStore<TProjection>(this IEventSourcingBuilder builder, Action<ElasticSearchProjectionStoreOptions> configureOptions) where TProjection : class
Parameters
builderIEventSourcingBuilderThe event-sourcing builder.
configureOptionsAction<ElasticSearchProjectionStoreOptions>Action to configure projection store options (node URI, index prefix, etc.).
Returns
- IEventSourcingBuilder
The same builder for fluent chaining.
Type Parameters
TProjectionThe projection type to store in ElasticSearch.
Remarks
This registers IProjectionStore<TProjection> backed by
ElasticSearchProjectionStore<TProjection>.
Use AddElasticSearchProjections(IEventSourcingBuilder, string, Action<ElasticSearchProjectionRegistrar>)
when registering multiple projections that share the same node URI.
Usage:
services.AddExcalibur(x => x.AddEventSourcing(es =>
{
es.AddElasticSearchProjectionStore<OrderSummary>(opts =>
{
opts.NodeUri = "https://es.example.com:9200";
opts.Index.IndexPrefix = "orders";
});
}));
AddElasticSearchProjectionStore<TProjection>(IEventSourcingBuilder, string, Action<ElasticSearchProjectionStoreOptions>?)
Registers a single ElasticSearch projection store for the specified projection type using the given ElasticSearch node URI.
public static IEventSourcingBuilder AddElasticSearchProjectionStore<TProjection>(this IEventSourcingBuilder builder, string nodeUri, Action<ElasticSearchProjectionStoreOptions>? configureOptions = null) where TProjection : class
Parameters
builderIEventSourcingBuilderThe event-sourcing builder.
nodeUristringThe ElasticSearch node URI.
configureOptionsAction<ElasticSearchProjectionStoreOptions>Optional action to further configure projection store options.
Returns
- IEventSourcingBuilder
The same builder for fluent chaining.
Type Parameters
TProjectionThe projection type to store in ElasticSearch.
AddElasticSearchProjection<TProjection>(IEventSourcingBuilder, Action<IProjectionBuilder<TProjection>>, Action<ElasticSearchProjectionStoreOptions>)
Registers a projection and the ElasticSearch store it lives in, in one call.
[RequiresUnreferencedCode("Implementations serialize the projection type reflectively; supply JsonSerializerOptions with a source-generated resolver for trimming and AOT.")]
[RequiresDynamicCode("Implementations serialize the projection type reflectively; supply JsonSerializerOptions with a source-generated resolver for trimming and AOT.")]
public static IEventSourcingBuilder AddElasticSearchProjection<TProjection>(this IEventSourcingBuilder builder, Action<IProjectionBuilder<TProjection>> configure, Action<ElasticSearchProjectionStoreOptions> configureStore) where TProjection : class, new()
Parameters
builderIEventSourcingBuilderThe event-sourcing builder.
configureAction<IProjectionBuilder<TProjection>>Configures what the projection folds — its mode and event handlers.
configureStoreAction<ElasticSearchProjectionStoreOptions>Configures where it is stored — the cluster, and this projection's own index.
Returns
- IEventSourcingBuilder
The same builder for fluent chaining.
Type Parameters
TProjectionThe projection type.
Remarks
A stored projection needs two things said about it: what it folds, and where it goes. Said separately they can be forgotten separately — a projection registered with no store folds into nothing — so this says both, and cannot be half made.
configureStore is required on purpose. The store options default their
node to http://localhost:9200, so a one-call API that let it be omitted would start
anywhere and reach a cluster only on a developer's own machine — a worse trap than the two calls
it replaces, because it fails where nobody is looking rather than at the keyboard.
services.AddExcalibur(x => x.AddEventSourcing(es => es
.AddElasticSearchProjection<OrderSummary>(
p => p.Async().When<OrderPlaced>((proj, e) => proj.Total = e.Amount),
o =>
{
o.NodeUris = [new Uri("http://es01:9200"), new Uri("http://es02:9200")];
o.Index.IndexName = "ordersummary";
})));
AddElasticSearchProjections(IEventSourcingBuilder, IConfiguration, Action<ElasticSearchProjectionRegistrar>)
Registers multiple ElasticSearch projection stores sharing one configured cluster.
[RequiresUnreferencedCode("Binds configuration to the options type reflectively; configure the stores in code for trimming and AOT.")]
[RequiresDynamicCode("Binds configuration to the options type reflectively; configure the stores in code for trimming and AOT.")]
public static IEventSourcingBuilder AddElasticSearchProjections(this IEventSourcingBuilder builder, IConfiguration section, Action<ElasticSearchProjectionRegistrar> configure)
Parameters
builderIEventSourcingBuilderThe event-sourcing builder.
sectionIConfigurationThe configuration section describing the shared cluster.
configureAction<ElasticSearchProjectionRegistrar>Action to register individual projection stores.
Returns
- IEventSourcingBuilder
The same builder for fluent chaining.
Remarks
The cluster is described once, in configuration, and every projection registered inside
configure binds it while keeping its own index.
AddElasticSearchProjections(IEventSourcingBuilder, Action<ElasticSearchProjectionStoreOptions>, Action<ElasticSearchProjectionRegistrar>)
Registers multiple ElasticSearch projection stores with shared options configuration.
public static IEventSourcingBuilder AddElasticSearchProjections(this IEventSourcingBuilder builder, Action<ElasticSearchProjectionStoreOptions> configureShared, Action<ElasticSearchProjectionRegistrar> configure)
Parameters
builderIEventSourcingBuilderThe event-sourcing builder.
configureSharedAction<ElasticSearchProjectionStoreOptions>Shared options applied to all projections.
configureAction<ElasticSearchProjectionRegistrar>Action to register individual projection stores.
Returns
- IEventSourcingBuilder
The same builder for fluent chaining.
AddElasticSearchProjections(IEventSourcingBuilder, string, Action<ElasticSearchProjectionRegistrar>)
Registers multiple ElasticSearch projection stores sharing a single node URI.
public static IEventSourcingBuilder AddElasticSearchProjections(this IEventSourcingBuilder builder, string nodeUri, Action<ElasticSearchProjectionRegistrar> configure)
Parameters
builderIEventSourcingBuilderThe event-sourcing builder.
nodeUristringThe shared ElasticSearch node URI.
configureAction<ElasticSearchProjectionRegistrar>Action to register individual projection stores.
Returns
- IEventSourcingBuilder
The same builder for fluent chaining.