Class ChronicleClient

Namespace
Cratis.Chronicle
Assembly
Cratis.Chronicle.dll

Represents an implementation of IChronicleClient.

public class ChronicleClient : IChronicleClient, IDisposable
Inheritance
ChronicleClient
Implements
Inherited Members
Extension Methods

Constructors

ChronicleClient()

Initializes a new instance of the ChronicleClient class.

public ChronicleClient()

Remarks

This initializes the client with the development connection string (Development), which includes the default development client credentials.

ChronicleClient(ChronicleOptions, IClientArtifactsProvider?, IServiceProvider?, IIdentityProvider?, ICorrelationIdAccessor?, IEventStoreNamespaceResolver?, ILoggerFactory?, INamingPolicy?)

Initializes a new instance of the ChronicleClient class.

public ChronicleClient(ChronicleOptions options, IClientArtifactsProvider? artifactsProvider = null, IServiceProvider? serviceProvider = null, IIdentityProvider? identityProvider = null, ICorrelationIdAccessor? correlationIdAccessor = null, IEventStoreNamespaceResolver? namespaceResolver = null, ILoggerFactory? loggerFactory = null, INamingPolicy? namingPolicy = null)

Parameters

options ChronicleOptions

ChronicleOptions to use.

artifactsProvider IClientArtifactsProvider

Optional IClientArtifactsProvider. Defaults to Default if not provided.

serviceProvider IServiceProvider

Optional IServiceProvider. Defaults to DefaultServiceProvider if not provided.

identityProvider IIdentityProvider

Optional IIdentityProvider. Defaults to BaseIdentityProvider if not provided.

correlationIdAccessor ICorrelationIdAccessor

Optional ICorrelationIdAccessor. Defaults to CorrelationIdAccessor if not provided.

namespaceResolver IEventStoreNamespaceResolver

Optional IEventStoreNamespaceResolver. Defaults to DefaultEventStoreNamespaceResolver if not provided.

loggerFactory ILoggerFactory

Optional ILoggerFactory. Defaults to a no-op factory if not provided.

namingPolicy INamingPolicy

Optional INamingPolicy. Defaults to DefaultNamingPolicy if not provided.

ChronicleClient(ChronicleConnectionString)

Initializes a new instance of the ChronicleClient class.

public ChronicleClient(ChronicleConnectionString connectionString)

Parameters

connectionString ChronicleConnectionString

ChronicleConnectionString to connect with.

ChronicleClient(IChronicleConnection, ChronicleOptions, IClientArtifactsProvider?, IServiceProvider?, IIdentityProvider?, ICorrelationIdAccessor?, IEventStoreNamespaceResolver?, ILoggerFactory?, INamingPolicy?)

Initializes a new instance of the ChronicleClient class.

public ChronicleClient(IChronicleConnection connection, ChronicleOptions options, IClientArtifactsProvider? artifactsProvider = null, IServiceProvider? serviceProvider = null, IIdentityProvider? identityProvider = null, ICorrelationIdAccessor? correlationIdAccessor = null, IEventStoreNamespaceResolver? namespaceResolver = null, ILoggerFactory? loggerFactory = null, INamingPolicy? namingPolicy = null)

Parameters

connection IChronicleConnection

IChronicleConnection to use.

options ChronicleOptions

Optional ChronicleOptions.

artifactsProvider IClientArtifactsProvider

Optional IClientArtifactsProvider. Defaults to Default if not provided.

serviceProvider IServiceProvider

Optional IServiceProvider. Defaults to DefaultServiceProvider if not provided.

identityProvider IIdentityProvider

Optional IIdentityProvider. Defaults to BaseIdentityProvider if not provided.

correlationIdAccessor ICorrelationIdAccessor

Optional ICorrelationIdAccessor. Defaults to CorrelationIdAccessor if not provided.

namespaceResolver IEventStoreNamespaceResolver

Optional IEventStoreNamespaceResolver. Defaults to DefaultEventStoreNamespaceResolver if not provided.

loggerFactory ILoggerFactory

Optional ILoggerFactory. Defaults to a no-op factory if not provided.

namingPolicy INamingPolicy

Optional INamingPolicy. Defaults to DefaultNamingPolicy if not provided.

ChronicleClient(string)

Initializes a new instance of the ChronicleClient class.

public ChronicleClient(string connectionString)

Parameters

connectionString string

Connection string to use.

Properties

CausationManager

Gets the ICausationManager for the client.

public ICausationManager CausationManager { get; }

Property Value

ICausationManager

Options

Gets the ChronicleOptions for the client.

public ChronicleOptions Options { get; }

Property Value

ChronicleOptions

Methods

Dispose()

public void Dispose()

EvictEventStores()

Evict every cached IEventStore, unsubscribing each one's RegisterAll handler from the shared connection lifecycle.

public void EvictEventStores()

Remarks

Used to release per-event-store subscriptions when the calling environment needs to fully reset client state without disposing the client itself — for example, between integration test classes that share an IChronicleClient instance. Without this, every IEventStore ever created stays subscribed to OnConnected and re-runs RegisterAll on subsequent reconnects, causing the kernel to receive a fanout of concurrent Ensure calls for the same event-store name.

GetEventStore(EventStoreName, EventStoreNamespaceName?)

Get an event store by name and optional namespace.

public Task<IEventStore> GetEventStore(EventStoreName name, EventStoreNamespaceName? @namespace = null)

Parameters

name EventStoreName

Name of the event store to get.

namespace EventStoreNamespaceName

Optional namespace.

Returns

Task<IEventStore>

IEventStore.

Remarks

If no namespace is specified, the default namespace will be used.

GetEventStores(CancellationToken)

List all the event stores.

public Task<IEnumerable<EventStoreName>> GetEventStores(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Optional CancellationToken.

Returns

Task<IEnumerable<EventStoreName>>

An asynchronous enumerable.