Class RaftClusterConfiguration
Allows setting up the special service used for configuration of IRaftCluster instance.
Inherited Members
Namespace: DotNext.Net.Cluster.Consensus.Raft
Assembly: DotNext.AspNetCore.Cluster.dll
Syntax
[CLSCompliant(false)]
public static class RaftClusterConfiguration
Methods
| Edit this page View SourceConfigureCluster<TConfig>(IServiceCollection)
Registers configurator of ICluster service registered as a service in DI container.
Declaration
public static IServiceCollection ConfigureCluster<TConfig>(this IServiceCollection services) where TConfig : class, IClusterMemberLifetime
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | A collection of services provided by DI container. |
Returns
Type | Description |
---|---|
IServiceCollection | A modified collection of services. |
Type Parameters
Name | Description |
---|---|
TConfig | The type implementing IClusterMemberLifetime. |
RestoreStateAsync<TStateMachine>(IApplicationBuilder, CancellationToken)
Restores the state machine.
Declaration
public static ValueTask RestoreStateAsync<TStateMachine>(this IApplicationBuilder app, CancellationToken token = default) where TStateMachine : SimpleStateMachine
Parameters
Type | Name | Description |
---|---|---|
IApplicationBuilder | app | The application builder. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing the state of the asynchronous operation. |
Type Parameters
Name | Description |
---|---|
TStateMachine | The type of the state machine. |
Remarks
The state machine must be registered previously with UseStateMachine<TStateMachine>(IServiceCollection) method.
UseConfigurationStorage<TStorage>(IServiceCollection)
Registers a service responsible for maintaining a list of cluster members.
Declaration
public static IServiceCollection UseConfigurationStorage<TStorage>(this IServiceCollection services) where TStorage : class, IClusterConfigurationStorage<UriEndPoint>
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | A collection of services. |
Returns
Type | Description |
---|---|
IServiceCollection | A modified collection of services. |
Type Parameters
Name | Description |
---|---|
TStorage | The type of the storage service. |
UseInMemoryConfigurationStorage(IServiceCollection, Action<ICollection<UriEndPoint>>)
Registers in-memory storage service for maintaining a list of cluster members.
Declaration
public static IServiceCollection UseInMemoryConfigurationStorage(this IServiceCollection services, Action<ICollection<UriEndPoint>> configuration)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | A collection of services. |
Action<ICollection<UriEndPoint>> | configuration | The delegate that allows to configure a list of cluster members at startup. |
Returns
Type | Description |
---|---|
IServiceCollection | A modified collection of services. |
Remarks
In-memory storage is not recommended for production use.
UsePersistenceEngine<TPersistentState>(IServiceCollection)
Registers custom persistence engine for the Write-Ahead Log based on PersistentState class.
Declaration
public static IServiceCollection UsePersistenceEngine<TPersistentState>(this IServiceCollection services) where TPersistentState : PersistentState
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | A collection of services provided by DI container. |
Returns
Type | Description |
---|---|
IServiceCollection | A modified collection of services. |
Type Parameters
Name | Description |
---|---|
TPersistentState | The type representing custom persistence engine. |
Remarks
If background compaction is configured for WAL then you can implement ILogCompactionSupport interface to provide custom logic for log compaction.
UsePersistenceEngine<TEngine, TImplementation>(IServiceCollection)
Registers custom persistence engine for the Write-Ahead Log based on PersistentState class.
Declaration
public static IServiceCollection UsePersistenceEngine<TEngine, TImplementation>(this IServiceCollection services) where TEngine : class where TImplementation : PersistentState, TEngine
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | A collection of services provided by DI container. |
Returns
Type | Description |
---|---|
IServiceCollection | A modified collection of services. |
Type Parameters
Name | Description |
---|---|
TEngine | An interface used for interaction with the persistence engine. |
TImplementation | The type representing custom persistence engine. |
Remarks
If background compaction is configured for WAL then you can implement ILogCompactionSupport interface to provide custom logic for log compaction.
UsePersistentConfigurationStorage(IServiceCollection, string)
Registers persistent storage service for maintaining a list of cluster members.
Declaration
public static IServiceCollection UsePersistentConfigurationStorage(this IServiceCollection services, string path)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | A collection of services. |
string | path | The absolute path to the folder on the local machine to store the list. |
Returns
Type | Description |
---|---|
IServiceCollection | A modified collection of services. |
UseStateMachine<TStateMachine>(IServiceCollection)
Registers the state machine and the write-ahead log for it.
Declaration
public static IServiceCollection UseStateMachine<TStateMachine>(this IServiceCollection services) where TStateMachine : class, IStateMachine
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | A collection of services provided by DI container. |
Returns
Type | Description |
---|---|
IServiceCollection | A modified collection of services. |
Type Parameters
Name | Description |
---|---|
TStateMachine | The type of the state machine. |