CBLibrary.ConsulRegister 1.0.1

.NET Core 2.1
NuGet\Install-Package CBLibrary.ConsulRegister -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
dotnet add package CBLibrary.ConsulRegister --version 1.0.1
<PackageReference Include="CBLibrary.ConsulRegister" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CBLibrary.ConsulRegister --version 1.0.1
#r "nuget: CBLibrary.ConsulRegister, 1.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install CBLibrary.ConsulRegister as a Cake Addin
#addin nuget:?package=CBLibrary.ConsulRegister&version=1.0.1

// Install CBLibrary.ConsulRegister as a Cake Tool
#tool nuget:?package=CBLibrary.ConsulRegister&version=1.0.1

Consul服务发现注册帮助组件

CBLibrary.ConsulRegister 1.0.1

Release Notes

Features

  • Consul服务发现注册帮助

Usages

实体
public class ServiceEntity
{
    /// <summary>
    /// 健康检查地址,默认: /api/health
    /// </summary>
    public string HealthCheckUrl { get; set; } = "/api/health";

    /// <summary>
    /// 异常服务定时清理间隔,单位:秒 默认60秒
    /// </summary>
    public int CriticalServiceCleanInterval { get; set; } = 1 * 60;

    /// <summary>
    /// 健康检查间隔,单位:秒 默认5秒
    /// </summary>
    public int HealthCheckInterval { get; set; } = 5;

    /// <summary>
    /// 超时时间,单位:秒 默认10秒
    /// </summary>
    public int Timeout { get; set; } = 10;


    /// <summary>
    /// 服务名称
    /// </summary>
    public string ServiceName { get; set; }

    /// <summary>
    /// 服务IP
    /// </summary>
    public string ServiceIP { get; set; }

    /// <summary>
    /// 服务端口号
    /// </summary>
    public int ServicePort { get; set; }

    /// <summary>
    /// 服务发现IP
    /// </summary>
    public string ConsulIP { get; set; }

    /// <summary>
    /// 服务发现端口号,默认: 8500
    /// </summary>
    public int ConsulPort { get; set; } = 8500;

    /// <summary>
    /// 数据中心名称,默认: xdx
    /// </summary>
    public string DataCenter { get; set; } = "xdx";
}
注册
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime lifetime)
{
    // register this service
    app.UseConsul(lifetime, new ServiceEntity
    {
        ServiceName = "MessageService",
        ServiceIP = NetworkHelper.LocalIPAddress,
        ServicePort = 22001,
        ConsulIP = "127.0.0.1",
        ConsulPort = 8500
    });
}
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 379 12/23/2019
1.0.0 670 8/7/2018

新增ServiceEntity属性