Table of Contents

Class MongoDbEventStoreOptions

Namespace
Excalibur.EventSourcing.MongoDB
Assembly
Excalibur.EventSourcing.MongoDB.dll

Configuration options for the MongoDB event store.

public sealed class MongoDbEventStoreOptions
Inheritance
MongoDbEventStoreOptions
Inherited Members

Properties

CollectionName

Gets or sets the collection name for event documents.

[Required]
public string CollectionName { get; set; }

Property Value

string

ConnectTimeoutSeconds

Gets or sets the connection timeout in seconds.

[Range(1, 2147483647)]
public int ConnectTimeoutSeconds { get; set; }

Property Value

int

ConnectionString

Gets or sets the MongoDB connection string.

[Required]
public string ConnectionString { get; set; }

Property Value

string

CounterCollectionName

Gets or sets the collection name for the global sequence counter.

[Required]
public string CounterCollectionName { get; set; }

Property Value

string

DatabaseName

Gets or sets the database name.

[Required]
public string DatabaseName { get; set; }

Property Value

string

EventTypeInfoResolver

Gets or sets a source-generated JSON type-info resolver covering the application's domain event types and the runtime types of the values it places in Metadata, enabling a reflection-free serialization path under trimming and native AOT.

public IJsonTypeInfoResolver? EventTypeInfoResolver { get; set; }

Property Value

IJsonTypeInfoResolver

The consumer's event type-info resolver, or null to serialize through reflection.

Remarks

Domain events are consumer types the framework cannot source-generate, so with no resolver the store serializes them through the reflection-based JsonSerializer. That works under the JIT, but a native-AOT application published with reflection-based serialization disabled has no reflection path to fall back on and the first append fails. Set this to a JsonSerializerContext (or any IJsonTypeInfoResolver) covering those types to remove that dependency.

The stored wire format does not vary with this setting. The resolver supplies type metadata only; the property naming policy, string-enum representation and null handling are the store's own and are applied to whichever resolver is in use, so events written with a resolver are byte-identical to events written without one and remain readable by a host configured either way.

Metadata values are typed object and are therefore written as their runtime type. Declare each closed value type the application actually stores -- string, int, bool and so on. Do not declare Dictionary<string, object> as a shortcut: it compiles and then throws on the values it was meant to cover.

MaxPoolSize

Gets or sets the maximum connection pool size.

[Range(1, 2147483647)]
public int MaxPoolSize { get; set; }

Property Value

int

ServerSelectionTimeoutSeconds

Gets or sets the server selection timeout in seconds.

[Range(1, 2147483647)]
public int ServerSelectionTimeoutSeconds { get; set; }

Property Value

int

UseSsl

Gets or sets a value indicating whether to use SSL/TLS.

public bool UseSsl { get; set; }

Property Value

bool

Methods

Validate()

Validates the options and throws if invalid.

public void Validate()

Exceptions

InvalidOperationException

Thrown when required options are missing.