Yzl.Extensions.SpringBoot.Admin.Client.Net
0.1.3
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Yzl.Extensions.SpringBoot.Admin.Client.Net --version 0.1.3
NuGet\Install-Package Yzl.Extensions.SpringBoot.Admin.Client.Net -Version 0.1.3
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="Yzl.Extensions.SpringBoot.Admin.Client.Net" Version="0.1.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Yzl.Extensions.SpringBoot.Admin.Client.Net" Version="0.1.3" />
<PackageReference Include="Yzl.Extensions.SpringBoot.Admin.Client.Net" />
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 Yzl.Extensions.SpringBoot.Admin.Client.Net --version 0.1.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Yzl.Extensions.SpringBoot.Admin.Client.Net, 0.1.3"
#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 Yzl.Extensions.SpringBoot.Admin.Client.Net@0.1.3
#: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=Yzl.Extensions.SpringBoot.Admin.Client.Net&version=0.1.3
#tool nuget:?package=Yzl.Extensions.SpringBoot.Admin.Client.Net&version=0.1.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Yzl.Extensions.SpringBoot.Admin.Client.Net 总体架构设计
1. 设计目标
Yzl.Extensions.SpringBoot.Admin.Client.Net 是一个 仿照 Spring Boot Admin Client 的 .NET 8 应用注册与心跳组件,主要目标:
- 自动注册 .NET 应用到 Spring Boot Admin Server
- 自动采集 Actuator 暴露的端点信息
- 定时发送健康心跳与元数据
- 支持日志管理、指标上报和多节点管理
等价于 Java 世界里的:
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
2. 总体架构图
┌────────────────────────────────────────────────────────────┐
│ Business Service (.NET 8) │
│ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ Yzl.Extensions.SpringBoot.Admin.Client.Net │ │
│ │ │ │
│ │ ┌────────────────────────────────────────────────┐ │ │
│ │ │ Registration Layer │ │ │
│ │ │ │ │ │
│ │ │ • SbaRegistrationService │ │ │
│ │ │ • Actuator Endpoints Metadata │ │ │
│ │ │ • HTTP Payload Construction │ │ │
│ │ └────────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ ┌────────────────────────────────────────────────┐ │ │
│ │ │ Heartbeat Layer │ │ │
│ │ │ │ │ │
│ │ │ • SbaHeartbeatService │ │ │
│ │ │ • Periodic Health & Status Reporting │ │ │
│ │ └────────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ ┌────────────────────────────────────────────────┐ │ │
│ │ │ HttpClient Factory │ │ │
│ │ │ │ │ │
│ │ │ • SbaHttpClientFactory │ │ │
│ │ │ • Basic Auth Support │ │ │
│ │ │ • HttpClient Caching / Reuse │ │ │
│ │ └────────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ ┌────────────────────────────────────────────────┐ │ │
│ │ │ Core Services Layer │ │ │
│ │ │ │ │ │
│ │ │ • ActuatorUrlResolver │ │ │
│ │ │ • IOptions<SbaClientOptions> │ │ │
│ │ │ • Registration & Heartbeat Orchestration │ │ │
│ │ └────────────────────────────────────────────────┘ │ │
│ └──────────────────────────────────────────────────────┘ │
│ │
│ ⚠ Integrates with Yzl.Extensions.Actuator to fetch │
│ exposed endpoints automatically │
│ │
└────────────────────────────────────────────────────────────┘
│
│ HTTP / REST
▼
┌────────────────────────────────────────────────────────────┐
│ Spring Boot Admin Server │
│ │
│ • Node Registration │
│ • Health Monitoring │
│ • Metrics Visualization │
│ • Logger Level Management │
│ • Multi-node Management │
└────────────────────────────────────────────────────────────┘
3. 核心组件说明
层级 组件 功能
Registration SbaRegistrationService 注册应用到 SBA Server,构建 metadata payload
Heartbeat SbaHeartbeatService 定时发送健康心跳,保持节点活跃
HttpClient SbaHttpClientFactory 创建 HttpClient,支持 Basic Auth,避免频繁创建
Core Services ActuatorUrlResolver 自动解析 ServiceUrl / ManagementUrl / HealthUrl
Core Services IOptions<SbaClientOptions> 配置读取和绑定
4. 方法调用流程
[Program.cs]
│
▼
AddSpringBootAdminClient() --> 注册 SBA Client 服务
│
▼
SbaRegistrationService.Resolve() --> 构建 metadata payload
│
▼
SbaHttpClientFactory.Create() --> 获取 HttpClient (缓存)
│
▼
HTTP POST /instances --> SBA Server 注册应用
│
▼
SbaHeartbeatService.PeriodicTick() --> 健康心跳上报
5. 配置示例
{
"spring": {
"application": {
"name": "sba.c.c.test"
},
"boot": {
"admin": {
"client": {
"Url": "http://10.1.24.141:16000",
"Username": "admin",
"Password": "1",
"RefreshInterval": "00:00:15"
}
}
}
},
"management": {
"server": {
"port": 27002
},
"endpoints": {
"web": {
"exposure": {
"basePath": "/actuator",
"include_": [ "health", "info", "metrics", "loggers" ],
"exclude_": [ "env" ]
}
}
}
}
}
using Yzl.Extensions.Actuator;
using Yzl.Extensions.SpringBoot.Admin.Client.Net;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
// ===== Yzl.Extensions.SpringBoot.Admin.Client.Net =====
builder.Services.AddSpringBootAdminClient(builder.Configuration);
var app = builder.Build();
app.MapGet("/", () => "Hello .NET 8 + SBA.Net.Client + Actuator!");
// ===== Yzl.Extensions.Actuator Endpoints(复用业务端口时,必须配置) =====
app.UseSpringNetActuatorMapEndpoints(builder.Configuration);
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();
6. 与Java对比
- 完全对应 Spring Boot Admin Clien
- 与 Yzl.Extensions.Actuator 紧密集成,减少重复配置
如有使用问题或更好建议,请与作者联系。EMail:306337420@QQ.com。
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Yzl.Extensions.Actuator (>= 0.1.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.