Class RaftClusterHttpHost
Represents a host of local Raft cluster node.
Inherited Members
Namespace: DotNext.Net.Cluster.Consensus.Raft.Http
Assembly: DotNext.AspNetCore.Cluster.dll
Syntax
public class RaftClusterHttpHost : Disposable, IDisposable, IHostedService, IAsyncDisposable
Remarks
This class is useful when you want to host multiple Raft clusters inside of the same application. For instance, if you want to implement sharding.
Constructors
View SourceRaftClusterHttpHost(IServiceProvider, string)
Creates a new unstarted Raft cluster locally.
Declaration
public RaftClusterHttpHost(IServiceProvider activationContext, string loggingCategory)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceProvider | activationContext | A provider of services required for initialization of IRaftHttpCluster implementation. |
| string | loggingCategory | The category of the logs to be produced by the implementation. |
Remarks
A list of required services that must be provided by activationContext:
| IOptionsMonitor<TOptions> of type HttpClusterMemberConfiguration | Provides configuration of the local cluster member. |
| ILoggerFactory | Provides logging infrastructure. |
A list of optional services that may be provided by activationContext:
| IInputChannel | Provides custom message processing. |
| IClusterMemberLifetime | Provides instance lifetime hooks. |
| IClusterConfigurationStorage<TAddress> of type UriEndPoint | Provides cluster configuration storage. |
| IHttpMessageHandlerFactory | Provides HttpMessageHandler implementation used by the local node to communicate with other cluster members. This is a key interface that can be used to share the same HTTP connection between multiple cluster instances when accessing the same node. |
| ClusterMemberAnnouncer<TAddress> of type UriEndPoint | Allows to announce a new node the cluster leader. |
| Func<T1, T2, TResult> with generic arguments TimeSpan, IRaftClusterMember, and IFailureDetector | Provides failure detection mechanism that allows the leader to remove unresponsive members from the cluster. |
You can supply these services from the implementation of IServiceProvider interface provided by Dependency Injection container or override some of the supplied services using ServiceProviderFactory.
Properties
View SourceCluster
Gets a local view of Raft cluster.
Declaration
public IRaftHttpCluster Cluster { get; }
Property Value
| Type | Description |
|---|---|
| IRaftHttpCluster |
Path
Gets relative URL path of Raft protocol handler.
Declaration
[CLSCompliant(false)]
public PathString Path { get; }
Property Value
| Type | Description |
|---|---|
| PathString |
Methods
View SourceDispatchAsync(HttpContext)
Dispatches HTTP request to this instance.
Declaration
[CLSCompliant(false)]
public Task DispatchAsync(HttpContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| HttpContext | context | HTTP request context. |
Returns
| Type | Description |
|---|---|
| Task | The task representing asynchronous dispatch. |
Remarks
This method is useful only when you want to host multiple Raft clusters inside of the same application. For instance, if you want to implement sharding.
Dispose(bool)
Releases managed and unmanaged resources associated with this object.
Declaration
protected override void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing | true if called from Dispose(); false if called from finalizer ~Disposable(). |
Overrides
View SourceDisposeAsync()
Stops hosting of local Raft node and releases all managed resources.
Declaration
public ValueTask DisposeAsync()
Returns
| Type | Description |
|---|---|
| ValueTask | The task representing asynchronous operation result. |
DisposeAsyncCore()
Releases managed resources associated with this object asynchronously.
Declaration
protected override ValueTask DisposeAsyncCore()
Returns
| Type | Description |
|---|---|
| ValueTask | The task representing asynchronous execution of this method. |
Overrides
Remarks
This method makes sense only if derived class implements IAsyncDisposable interface.
StartAsync(CancellationToken)
Starts hosting of local Raft node.
Declaration
public Task StartAsync(CancellationToken token)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | token | The token that can be used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task | The task representing asynchronous operation result. |
StopAsync(CancellationToken)
Stops hosting of local Raft node.
Declaration
public Task StopAsync(CancellationToken token)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | token | The token that can be used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task | The task representing asynchronous operation result. |