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
optionsChronicleOptionsChronicleOptions to use.
artifactsProviderIClientArtifactsProviderOptional IClientArtifactsProvider. Defaults to Default if not provided.
serviceProviderIServiceProviderOptional IServiceProvider. Defaults to DefaultServiceProvider if not provided.
identityProviderIIdentityProviderOptional IIdentityProvider. Defaults to BaseIdentityProvider if not provided.
correlationIdAccessorICorrelationIdAccessorOptional ICorrelationIdAccessor. Defaults to CorrelationIdAccessor if not provided.
namespaceResolverIEventStoreNamespaceResolverOptional IEventStoreNamespaceResolver. Defaults to DefaultEventStoreNamespaceResolver if not provided.
loggerFactoryILoggerFactoryOptional ILoggerFactory. Defaults to a no-op factory if not provided.
namingPolicyINamingPolicyOptional INamingPolicy. Defaults to DefaultNamingPolicy if not provided.
ChronicleClient(ChronicleConnectionString)
Initializes a new instance of the ChronicleClient class.
public ChronicleClient(ChronicleConnectionString connectionString)
Parameters
connectionStringChronicleConnectionStringChronicleConnectionString 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
connectionIChronicleConnectionIChronicleConnection to use.
optionsChronicleOptionsOptional ChronicleOptions.
artifactsProviderIClientArtifactsProviderOptional IClientArtifactsProvider. Defaults to Default if not provided.
serviceProviderIServiceProviderOptional IServiceProvider. Defaults to DefaultServiceProvider if not provided.
identityProviderIIdentityProviderOptional IIdentityProvider. Defaults to BaseIdentityProvider if not provided.
correlationIdAccessorICorrelationIdAccessorOptional ICorrelationIdAccessor. Defaults to CorrelationIdAccessor if not provided.
namespaceResolverIEventStoreNamespaceResolverOptional IEventStoreNamespaceResolver. Defaults to DefaultEventStoreNamespaceResolver if not provided.
loggerFactoryILoggerFactoryOptional ILoggerFactory. Defaults to a no-op factory if not provided.
namingPolicyINamingPolicyOptional INamingPolicy. Defaults to DefaultNamingPolicy if not provided.
ChronicleClient(string)
Initializes a new instance of the ChronicleClient class.
public ChronicleClient(string connectionString)
Parameters
connectionStringstringConnection string to use.
Properties
CausationManager
Gets the ICausationManager for the client.
public ICausationManager CausationManager { get; }
Property Value
Options
Gets the ChronicleOptions for the client.
public ChronicleOptions Options { get; }
Property Value
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
nameEventStoreNameName of the event store to get.
namespaceEventStoreNamespaceNameOptional namespace.
Returns
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
cancellationTokenCancellationTokenOptional CancellationToken.
Returns
- Task<IEnumerable<EventStoreName>>
An asynchronous enumerable.