Table of Contents

Class SqliteEventSourcingServiceCollectionExtensions

Namespace
Microsoft.Extensions.DependencyInjection
Assembly
Excalibur.EventSourcing.Sqlite.dll

Extension methods for configuring SQLite event sourcing services.

public static class SqliteEventSourcingServiceCollectionExtensions
Inheritance
SqliteEventSourcingServiceCollectionExtensions
Inherited Members

Methods

AddSqliteSubscriptionCheckpointStore(IServiceCollection, string, string)

Registers the SQLite-backed durable subscription checkpoint store.

public static IServiceCollection AddSqliteSubscriptionCheckpointStore(this IServiceCollection services, string connectionString, string table = "SubscriptionCheckpoints")

Parameters

services IServiceCollection

The service collection.

connectionString string

The connection string for the checkpoint database.

table string

The checkpoint table name. Default: "SubscriptionCheckpoints".

Returns

IServiceCollection

The service collection, for chaining.

Remarks

Register this whenever a catch-up subscription or a global-stream projection runs in a process that can restart. SQLite is embedded, so it is tempting to treat the checkpoint as process state — but the process is exactly what restarts. Without this the core registers an IN-MEMORY store and every subscription replays the whole stream on each start.

The in-memory default is registered with TryAdd, so this registration wins whether it runs before or after the core's. Requires the checkpoint table from the shipped schema script.

UseSqlite(IEventSourcingBuilder, IConfiguration)

Configures SQLite as the event sourcing provider using an IConfiguration section.

[RequiresUnreferencedCode("Binding configuration to the options type reflects over its members, which trimming may remove. Configure the options in code instead of binding IConfiguration.")]
[RequiresDynamicCode("Binding configuration to the options type can require runtime code generation, which native AOT does not support. Configure the options in code instead of binding IConfiguration.")]
public static IEventSourcingBuilder UseSqlite(this IEventSourcingBuilder builder, IConfiguration configuration)

Parameters

builder IEventSourcingBuilder

The event sourcing builder.

configuration IConfiguration

The configuration section to bind to SqliteEventSourcingOptions.

Returns

IEventSourcingBuilder

The builder for fluent chaining.

Exceptions

InvalidOperationException

Thrown when ConnectionString is not configured.

UseSqlite(IEventSourcingBuilder, Action<SqliteEventSourcingOptions>)

Configures SQLite as the event sourcing provider.

public static IEventSourcingBuilder UseSqlite(this IEventSourcingBuilder builder, Action<SqliteEventSourcingOptions> configure)

Parameters

builder IEventSourcingBuilder

The event sourcing builder.

configure Action<SqliteEventSourcingOptions>

Configuration action for SQLite options.

Returns

IEventSourcingBuilder

The builder for fluent chaining.

Examples

services.AddExcalibur(x => x.AddEventSourcing(es =>
{
    es.UseSqlite(options =>
    {
        options.ConnectionString = "Data Source=events.db";
    });
}));

Exceptions

InvalidOperationException

Thrown when ConnectionString is not configured.