Show / Hide Table of Contents

Class ConfigurationExtensions

Provides a set of methods for enabling Raft support in ASP.NET Core HTTP application.

Inheritance
object
ConfigurationExtensions
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DotNext.Net.Cluster.Consensus.Raft.Http
Assembly: DotNext.AspNetCore.Cluster.dll
Syntax
public static class ConfigurationExtensions

Methods

| Edit this page View Source

ConfigureLocalNode(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.

| Edit this page View Source

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.

| Edit this page View Source

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
JoinCluster(IHostBuilder)
| Edit this page View Source

JoinCluster(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
JoinCluster(IHostBuilder, Action<HttpClusterMemberConfiguration, IConfiguration, IHostEnvironment>)
| Edit this page View Source

JoinCluster(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
JoinCluster(IHostBuilder, Func<IConfiguration, IHostEnvironment, IConfiguration>)
| Edit this page View Source

JoinCluster(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
JoinCluster(IHostBuilder, string)
| Edit this page View Source

JoinCluster(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>).

| Edit this page View Source

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>).

| Edit this page View Source

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>).

| Edit this page View Source

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>).

| Edit this page View Source

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.

| Edit this page View Source

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.

  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾