NetPro.ConsulClient 6.0.3-beta.2

This is a prerelease version of NetPro.ConsulClient.
There is a newer version of this package available.
See the version list below for details.
dotnet add package NetPro.ConsulClient --version 6.0.3-beta.2
NuGet\Install-Package NetPro.ConsulClient -Version 6.0.3-beta.2
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.
<PackageReference Include="NetPro.ConsulClient" Version="6.0.3-beta.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NetPro.ConsulClient --version 6.0.3-beta.2
#r "nuget: NetPro.ConsulClient, 6.0.3-beta.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install NetPro.ConsulClient as a Cake Addin
#addin nuget:?package=NetPro.ConsulClient&version=6.0.3-beta.2&prerelease

// Install NetPro.ConsulClient as a Cake Tool
#tool nuget:?package=NetPro.ConsulClient&version=6.0.3-beta.2&prerelease

NetPro.Proxy使用

NuGet

Consul 客户端

使用

如在容器中使用,需要配置如下LANIP和PORT环境变量,默认便利本机所有网卡地址与分配给程序的默认端口,示例如下: 宿主机IP地址 LANIP=192.168.1.1 PORT 端口号 PORT=5000

appsetting.json
  • 增加以下配置节点
"ConsulOption": {
        "Enabled": false,//是否开启,不配置默认开启,不影响启动
		"HealthPath": "/HealthCheck",//可空不填,默认HealthCheck
		"ServiceName": "xxx.api",//可空不填,取运行时程序集名称
		"EndPoint": "http://localhost:8500" consul服务地址
        "Tags": [ "HUHU"] //tag
	}

如果基于NetPro.WebApi的项目,只需要以上配置即可,如不是基于NetPro.WebApi的项目,需手动按一下初始化组件

启用服务
public void ConfigureServices(IServiceCollection services, IConfiguration configuration = null)
        {
            services.AddConsul(configuration);
        }

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseConsul();
        }
ublic class ConsulDemoController : ControllerBase
    {

        private readonly ILogger<TimeZoneDemoController> _logger;
        private readonly IConsulClient _consulClient;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="consulClient"></param>
        public TimeZoneDemoController(ILogger<TimeZoneDemoController> logger,
        IConsulClient consulClient)
        {
            _logger = logger;
            _consulClient=consulClient;
        }

        /// <summary>
        /// consul发现服务
        /// </summary>
        [HttpGet("DiscoveryServices")]
        [ProducesResponseType(200, Type = typeof(ResponseResult))]
        public async Task<IActionResult> DiscoveryServices(string serviceName = "XXX.API")
        {
            //以下几种方式都可拿到注册的服务地址
            var result = await _consulClient.Agent.DiscoveryAsync();
            var result1 = await _consulClient.Catalog.DiscoveryAsync(serviceName);
            var result2 = await _consulClient.DiscoveryAsync(serviceName);
            return Ok(new { result, result1, result2 });
        }
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on NetPro.ConsulClient:

Repository Stars
LeonKou/NetPro
🌈An enhanced version with clean architecture of asp.netcore,efficiently manage startup,Support for netcore3.1/6.0
Version Downloads Last updated
6.0.16 120 7/24/2023
6.0.15 128 7/19/2022
6.0.14 130 7/10/2022
6.0.13 118 6/15/2022
6.0.12 108 6/15/2022
6.0.11 112 6/15/2022
6.0.10 124 6/11/2022
6.0.9 123 6/8/2022
6.0.8 117 5/26/2022
6.0.8-beta.3 463 5/24/2022
6.0.8-beta.2 102 5/24/2022
6.0.7 127 5/18/2022
6.0.6 124 4/28/2022
6.0.5 124 3/30/2022
6.0.5-beta.20 117 4/27/2022
6.0.5-beta.19 110 4/25/2022
6.0.5-beta.18 109 4/22/2022
6.0.5-beta.17 114 4/16/2022
6.0.5-beta.16 185 4/8/2022
6.0.5-beta.15 115 4/8/2022
6.0.5-beta.14 125 4/7/2022
6.0.5-beta.13 119 4/7/2022
6.0.5-beta.12 118 4/6/2022
6.0.5-beta.11 114 4/6/2022
6.0.5-beta.10 114 3/31/2022
6.0.5-beta.9 180 3/26/2022
6.0.5-beta.8 133 3/22/2022
6.0.5-beta.7 134 3/21/2022
6.0.5-beta.6 127 3/14/2022
6.0.5-beta.5 125 3/2/2022
6.0.5-beta.4 122 2/22/2022
6.0.5-beta.3 123 2/18/2022
6.0.5-beta.2 114 2/18/2022
6.0.5-beta.1 124 2/16/2022
6.0.4 438 2/10/2022
6.0.3 418 2/9/2022
6.0.3-beta.9 117 2/10/2022
6.0.3-beta.7 143 1/27/2022
6.0.3-beta.6 129 1/19/2022
6.0.3-beta.5 144 1/17/2022
6.0.3-beta.4 141 1/16/2022
6.0.3-beta.3 136 1/14/2022
6.0.3-beta.2 128 1/13/2022
6.0.3-beta.1 160 1/11/2022
6.0.2 293 1/6/2022
1.0.0 341 12/20/2021