Class ConfigurationExtensions
Provides a set of methods for enabling Raft support in ASP.NET Core HTTP application.
Inherited Members
Namespace: DotNext.Net.Cluster.Consensus.Raft.Http
Assembly: DotNext.AspNetCore.Cluster.dll
Syntax
public static class ConfigurationExtensions
Methods
| Edit this page View SourceConfigureLocalNode(IServiceCollection, IConfiguration)
Allows to inject ICluster, IRaftCluster, IPeerMesh to application services and establishes network communication with other cluster members.
Declaration
public static IServiceCollection ConfigureLocalNode(this IServiceCollection services, IConfiguration memberConfig)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | The collection of services. |
IConfiguration | memberConfig | The configuration of local cluster node. |
Returns
Type | Description |
---|---|
IServiceCollection | The modified collection of services. |
Remarks
This method should not be used together with JoinCluster(IHostBuilder) because it has the same semantics. It's here just for corner case when you want to implement choice between hosted and embedded mode in the same app or library.
ConfigureLocalNode(IServiceCollection, Action<HttpClusterMemberConfiguration>)
Allows to inject ICluster, IRaftCluster, IPeerMesh<TPeer> to application services and establishes network communication with other cluster members.
Declaration
public static IServiceCollection ConfigureLocalNode(this IServiceCollection services, Action<HttpClusterMemberConfiguration> memberConfig)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | The collection of services. |
Action<HttpClusterMemberConfiguration> | memberConfig | The configuration of local cluster node. |
Returns
Type | Description |
---|---|
IServiceCollection | The modified collection of services. |
Remarks
This method should not be used together with JoinCluster(IHostBuilder) because it has the same semantics. It's here just for corner case when you want to implement choice between hosted and embedded mode in the same app or library.
JoinCluster(WebApplicationBuilder)
Allows to inject ICluster, IRaftCluster, IPeerMesh<TPeer> to application services and establishes network communication with other cluster members.
Declaration
[CLSCompliant(false)]
public static void JoinCluster(this WebApplicationBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
WebApplicationBuilder | builder | The application builder. |
See Also
| Edit this page View SourceJoinCluster(WebApplicationBuilder, Action<HttpClusterMemberConfiguration, IConfiguration, IHostEnvironment>)
Allows to inject ICluster, IRaftCluster, IPeerMesh<TPeer> to application services and establishes network communication with other cluster members.
Declaration
[CLSCompliant(false)]
public static void JoinCluster(this WebApplicationBuilder builder, Action<HttpClusterMemberConfiguration, IConfiguration, IHostEnvironment> memberConfig)
Parameters
Type | Name | Description |
---|---|---|
WebApplicationBuilder | builder | The application builder. |
Action<HttpClusterMemberConfiguration, IConfiguration, IHostEnvironment> | memberConfig | The delegate that allows to resolve location of local member configuration. |
See Also
| Edit this page View SourceJoinCluster(WebApplicationBuilder, Func<IConfiguration, IHostEnvironment, IConfiguration>)
Allows to inject ICluster, IRaftCluster, IPeerMesh<TPeer> to application services and establishes network communication with other cluster members.
Declaration
[CLSCompliant(false)]
public static void JoinCluster(this WebApplicationBuilder builder, Func<IConfiguration, IHostEnvironment, IConfiguration> memberConfig)
Parameters
Type | Name | Description |
---|---|---|
WebApplicationBuilder | builder | The application builder. |
Func<IConfiguration, IHostEnvironment, IConfiguration> | memberConfig | The delegate that allows to resolve location of local member configuration. |
See Also
| Edit this page View SourceJoinCluster(WebApplicationBuilder, string)
Allows to inject ICluster, IRaftCluster, IPeerMesh<TPeer> to application services and establishes network communication with other cluster members.
Declaration
[CLSCompliant(false)]
public static void JoinCluster(this WebApplicationBuilder builder, string memberConfigSection)
Parameters
Type | Name | Description |
---|---|---|
WebApplicationBuilder | builder | The application builder. |
string | memberConfigSection | The name of local member configuration section. |
See Also
| Edit this page View SourceJoinCluster(IHostBuilder)
Allows to inject ICluster, IRaftCluster, IPeerMesh<TPeer> to application services and establishes network communication with other cluster members.
Declaration
public static IHostBuilder JoinCluster(this IHostBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
IHostBuilder | builder | The host builder. |
Returns
Type | Description |
---|---|
IHostBuilder | The modified host builder. |
Remarks
Should be called exactly after ConfigureWebHost(IHostBuilder, Action<IWebHostBuilder>) or ConfigureWebHostDefaults(IHostBuilder, Action<IWebHostBuilder>).
JoinCluster(IHostBuilder, Action<HttpClusterMemberConfiguration, IConfiguration, IHostEnvironment>)
Allows to inject ICluster, IRaftCluster, IPeerMesh<TPeer> to application services and establishes network communication with other cluster members.
Declaration
public static IHostBuilder JoinCluster(this IHostBuilder builder, Action<HttpClusterMemberConfiguration, IConfiguration, IHostEnvironment> memberConfig)
Parameters
Type | Name | Description |
---|---|---|
IHostBuilder | builder | The host builder. |
Action<HttpClusterMemberConfiguration, IConfiguration, IHostEnvironment> | memberConfig | The delegate that allows to resolve location of local member configuration. |
Returns
Type | Description |
---|---|
IHostBuilder | The modified host builder. |
Remarks
Should be called exactly after ConfigureWebHost(IHostBuilder, Action<IWebHostBuilder>) or ConfigureWebHostDefaults(IHostBuilder, Action<IWebHostBuilder>).
JoinCluster(IHostBuilder, Func<IConfiguration, IHostEnvironment, IConfiguration>)
Allows to inject ICluster, IRaftCluster, IPeerMesh<TPeer> to application services and establishes network communication with other cluster members.
Declaration
public static IHostBuilder JoinCluster(this IHostBuilder builder, Func<IConfiguration, IHostEnvironment, IConfiguration> memberConfig)
Parameters
Type | Name | Description |
---|---|---|
IHostBuilder | builder | The host builder. |
Func<IConfiguration, IHostEnvironment, IConfiguration> | memberConfig | The delegate that allows to resolve location of local member configuration. |
Returns
Type | Description |
---|---|
IHostBuilder | The modified host builder. |
Remarks
Should be called exactly after ConfigureWebHost(IHostBuilder, Action<IWebHostBuilder>) or ConfigureWebHostDefaults(IHostBuilder, Action<IWebHostBuilder>).
JoinCluster(IHostBuilder, string)
Allows to inject ICluster, IRaftCluster, IPeerMesh<TPeer> to application services and establishes network communication with other cluster members.
Declaration
public static IHostBuilder JoinCluster(this IHostBuilder builder, string memberConfigSection)
Parameters
Type | Name | Description |
---|---|---|
IHostBuilder | builder | The host builder. |
string | memberConfigSection | The name of local member configuration section. |
Returns
Type | Description |
---|---|
IHostBuilder | The modified host builder. |
Remarks
Should be called exactly after ConfigureWebHost(IHostBuilder, Action<IWebHostBuilder>) or ConfigureWebHostDefaults(IHostBuilder, Action<IWebHostBuilder>).
RedirectToLeader(IApplicationBuilder, PathString, int?, Func<HttpResponse, Uri, Task>?)
Defines that the relative path should be handled by a leader node only.
Declaration
[CLSCompliant(false)]
public static IApplicationBuilder RedirectToLeader(this IApplicationBuilder builder, PathString path, int? applicationPortHint = null, Func<HttpResponse, Uri, Task>? redirection = null)
Parameters
Type | Name | Description |
---|---|---|
IApplicationBuilder | builder | The request processing pipeline builder. |
PathString | path | The path that a leader must handle. |
int? | applicationPortHint | The port number to be inserted into Location header instead of automatically detected port of the local TCP listener. |
Func<HttpResponse, Uri, Task> | redirection | The redirection logic. |
Returns
Type | Description |
---|---|
IApplicationBuilder | The request pipeline builder. |
Remarks
If the current node is not the leader then request will be
redirected automatically to the leader node with 307 (Temporary Redirect preserve method).
If there are no consensus then the request will be failed with 503 (Service Unavailable).
You can override redirection behavior using custom redirection
.
applicationPortHint
used to highlight the real port of the application endpoints in the cluster.
This parameter can be used if your deployment is based on Docker. If it is not specified then router trying to add
local port of the TCP listener. This may be invalid due to port mappings in Docker.
UseConsensusProtocolHandler(IApplicationBuilder)
Setup Raft protocol handler as middleware for the specified application.
Declaration
[CLSCompliant(false)]
public static IApplicationBuilder UseConsensusProtocolHandler(this IApplicationBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
IApplicationBuilder | builder | The application builder. |
Returns
Type | Description |
---|---|
IApplicationBuilder | The configured application builder. |