VOOZH about

URL: https://www.nuget.org/packages/Galosys.Foundation.NacosNaming/

⇱ NuGet Gallery | Galosys.Foundation.NacosNaming 26.5.20.1




Galosys.Foundation.NacosNaming 26.5.20.1

dotnet add package Galosys.Foundation.NacosNaming --version 26.5.20.1
 
 
NuGet\Install-Package Galosys.Foundation.NacosNaming -Version 26.5.20.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.
<PackageReference Include="Galosys.Foundation.NacosNaming" Version="26.5.20.1" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Galosys.Foundation.NacosNaming" Version="26.5.20.1" />
 
Directory.Packages.props
<PackageReference Include="Galosys.Foundation.NacosNaming" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Galosys.Foundation.NacosNaming --version 26.5.20.1
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Galosys.Foundation.NacosNaming, 26.5.20.1"
 
 
#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.
#:package Galosys.Foundation.NacosNaming@26.5.20.1
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Galosys.Foundation.NacosNaming&version=26.5.20.1
 
Install as a Cake Addin
#tool nuget:?package=Galosys.Foundation.NacosNaming&version=26.5.20.1
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Galosys.Foundation.NacosNaming

成熟度: 🟡 可用 — 功能完整,测试或文档可能不完善

基于 Nacos 的服务注册与发现模块,提供服务注册、发现及相关扩展功能。

功能概述

  • 服务注册: 将应用服务自动注册到 Nacos 服务端
  • 服务发现: 支持从 Nacos 获取健康服务实例
  • 服务健康检查: 支持健康实例筛选
  • 元数据管理: 支持自定义服务元数据

依赖项

  • Nacos.SDK
  • Microsoft.Extensions.Options
  • Microsoft.Extensions.ServiceDiscovery

配置说明

appsettings.json 中配置 Nacos 相关参数:

{
 "Nacos": {
 "ServerAddr": ["http://localhost:8848"],
 "UserName": "nacos",
 "Password": "nacos",
 "ClusterName": "DEFAULT",
 "GroupName": "DEFAULT_GROUP",
 "RegisterEnabled": true,
 "AccessKey": "",
 "SecretKey": "",
 "Endpoint": ""
 }
}

配置项说明

配置项 类型 默认值 说明
ServerAddr List<string> - Nacos 服务器地址
UserName string - 用户名
Password string - 密码
ClusterName string DEFAULT 集群名称
GroupName string DEFAULT_GROUP 分组名称
RegisterEnabled bool true 是否启用服务注册
AccessKey string - 访问密钥
SecretKey string - _secretKey 密钥
Endpoint string - 端点地址

使用方法

1. 服务注册

模块会自动将服务注册到 Nacos,无需手动配置:

// 自动从环境变量获取服务地址和端口进行注册
// 服务名称自动从环境变量或配置中获取

2. 服务发现

通过 HTTP 端点调用其他已注册服务:

// 使用 HttpClient 直接请求 Nacos 注册的服务
// 格式: http://{服务名}

3. 扩展方法

获取健康服务实例地址:

var instance = await nacosNamingService.SelectOneHealthyInstance(
 serviceName,
 groupName,
 clusterList,
 healthyOnly
);

instance.TryGetHealthyUrl(out var url);
// url 格式: http://ip:port

注意事项

  • 确保 Nacos 服务端正常运行
  • 服务端口需与 Nacos 配置一致
  • 生产环境请妥善保管用户名密码
  • 可通过 RegisterEnabled 禁用注册功能,适用于网关等场景
Product Versions Compatible and additional computed target framework versions.
.NET net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Galosys.Foundation.NacosNaming:

Package Downloads
Galosys.Foundation.Yarp.NacosNaming

Galosys.Foundation快速开发库

Galosys.Micro.App

Galosys.Foundation快速开发库

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
26.5.20.1 114 5/20/2026
26.5.19.1 102 5/19/2026
26.5.18.1 116 5/18/2026
26.5.15.1 114 5/15/2026
26.5.12.3 118 5/12/2026
26.5.12.2 96 5/12/2026
26.4.27.1-rc1 107 4/26/2026
26.4.25.1-rc1 102 4/25/2026
26.4.22.2-rc7 109 4/22/2026
26.4.22.2-rc6 102 4/22/2026
26.4.22.2-rc4 102 4/22/2026
26.4.22.2-rc3 107 4/22/2026
26.4.19.1-rc1 106 4/19/2026
26.4.12.8-rc1 114 4/12/2026
26.4.12.7-rc1 110 4/12/2026
26.4.12.5-rc1 92 4/12/2026
26.1.30.1-rc1 172 1/30/2026
26.1.29.1 172 1/29/2026
26.1.28.5 160 1/28/2026
26.1.28.4 166 1/28/2026
Loading failed