Healnet.Infrastructure 1.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Healnet.Infrastructure --version 1.1.1
                    
NuGet\Install-Package Healnet.Infrastructure -Version 1.1.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="Healnet.Infrastructure" Version="1.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Healnet.Infrastructure" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Healnet.Infrastructure" />
                    
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 Healnet.Infrastructure --version 1.1.1
                    
#r "nuget: Healnet.Infrastructure, 1.1.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 Healnet.Infrastructure@1.1.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=Healnet.Infrastructure&version=1.1.1
                    
Install as a Cake Addin
#tool nuget:?package=Healnet.Infrastructure&version=1.1.1
                    
Install as a Cake Tool

Healnet.Infrastructure 基础设施模块

概述

Healnet.Infrastructure 是 Healnet 框架的基础设施层,提供各种基础设施服务的封装和集成,包括数据库、缓存、消息队列、认证授权、分布式服务等核心组件。

模块架构

┌─────────────────────────────────────────────────────────────────┐
│                    Healnet.Infrastructure                      │
├─────────────────────────────────────────────────────────────────┤
│  数据存储层                                                    │
│  ├── MongoDB          - NoSQL 文档数据库                        │
│  ├── SqlSugar         - SQL ORM                               │
│  ├── ClickHouse       - 列式数据库                             │
│  └── ElasticSearch    - 全文搜索引擎                           │
├─────────────────────────────────────────────────────────────────┤
│  缓存与消息层                                                  │
│  ├── Redis            - 分布式缓存                            │
│  └── RabbitMQ         - 消息队列                              │
├─────────────────────────────────────────────────────────────────┤
│  安全认证层                                                    │
│  ├── Authentication   - JWT 认证                              │
│  └── Security         - 安全工具                              │
├─────────────────────────────────────────────────────────────────┤
│  分布式服务层                                                  │
│  ├── Consul           - 服务发现与配置                         │
│  ├── YARP             - API 网关                              │
│  ├── gRPC             - 远程过程调用                           │
│  └── Http             - HTTP 客户端                           │
├─────────────────────────────────────────────────────────────────┤
│  运维监控层                                                    │
│  ├── OpenTelemetry    - 可观测性                              │
│  ├── Logging          - 日志记录                              │
│  ├── HealthChecks     - 健康检查                              │
│  └── Resilience       - 弹性处理                              │
├─────────────────────────────────────────────────────────────────┤
│  其他工具                                                      │
│  ├── Swagger          - API 文档                              │
│  ├── OSS              - 对象存储                              │
│  ├── UnitOfWork       - 工作单元                              │
│  ├── Middleware       - 中间件                                │
│  └── AI               - AI 服务集成                           │
└─────────────────────────────────────────────────────────────────┘

模块列表

模块 说明 状态
MongoDB 通用仓储基类,支持审计字段、软删除、多租户 ✅ 完成
SqlSugar SQL ORM 封装,支持多种数据库 ✅ 完成
Redis 分布式缓存服务,支持分布式锁、管道操作 ✅ 完成
RabbitMQ 消息队列服务,支持死信队列、延迟队列 ✅ 完成
Authentication JWT 认证服务,支持 Token 刷新和撤销 ✅ 完成
Security 安全工具类,包含加密解密、数据脱敏等 ✅ 完成
Consul 服务发现与配置管理 ✅ 完成
YARP API 网关,支持路由和负载均衡 ✅ 完成
gRPC gRPC 服务封装,支持客户端和服务端 ✅ 完成
Http HTTP 客户端封装,支持重试和熔断 ✅ 完成
OpenTelemetry 可观测性集成,支持 tracing、metrics、logging ✅ 完成
Logging 日志记录扩展,支持多种输出 ✅ 完成
HealthChecks 健康检查服务 ✅ 完成
Resilience 弹性处理,支持重试、熔断、限流 ✅ 完成
Swagger API 文档生成 ✅ 完成
OSS 对象存储服务,支持多种云存储 ✅ 完成
UnitOfWork 工作单元模式实现 ✅ 完成
Middleware 通用中间件集合 ✅ 完成
AI AI 服务集成,支持多框架统一接口 ✅ 完成
ClickHouse 列式数据库集成 ✅ 完成
ElasticSearch 全文搜索集成 ✅ 完成

快速开始

1. 安装依赖


<PackageReference Include="Healnet.Infrastructure" Version="1.1.0" />


<PackageReference Include="Healnet.Infrastructure.Redis" Version="1.1.0" />
<PackageReference Include="Healnet.Infrastructure.MongoDB" Version="1.1.0" />
<PackageReference Include="Healnet.Infrastructure.Authentication" Version="1.1.0" />

2. 服务注册

// Program.cs
var builder = WebApplication.CreateBuilder(args);

// 添加基础设施服务
builder.Services.AddInfrastructure(builder.Configuration);

// 或选择性添加模块
builder.Services.AddRedis(builder.Configuration);
builder.Services.AddMongoDB(builder.Configuration);
builder.Services.AddJwtAuth(builder.Configuration);
builder.Services.AddRabbitMQ(builder.Configuration);

var app = builder.Build();

// 配置中间件
app.UseAuthentication();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI();

app.Run();

3. 配置示例

{
  "Healnet": {
    "Redis": {
      "ConnectionString": "localhost:6379",
      "InstanceName": "Healnet:",
      "ConnectTimeout": 5000
    },
    "MongoDB": {
      "ConnectionString": "mongodb://localhost:27017",
      "DatabaseName": "HealnetDB",
      "EnableAudit": true
    },
    "Jwt": {
      "SecretKey": "your-256-bit-secret-key",
      "Issuer": "Healnet",
      "Audience": "Healnet.Api",
      "AccessTokenExpireMinutes": 30
    },
    "RabbitMQ": {
      "HostName": "localhost",
      "UserName": "guest",
      "Password": "guest",
      "VirtualHost": "/"
    }
  }
}

核心特性

数据存储

  • MongoDB: 通用仓储、审计字段、软删除、多租户、全文搜索、聚合查询
  • SqlSugar: ORM 操作、事务管理、查询构建器、批量操作
  • ClickHouse: 列式存储、实时分析、高性能查询
  • ElasticSearch: 全文搜索、聚合分析、自动补全

缓存与消息

  • Redis: 分布式缓存、分布式锁、管道操作、Lua 脚本、发布订阅
  • RabbitMQ: 消息发布订阅、死信队列、延迟队列、消息确认、批量处理

安全认证

  • JWT: Token 生成、验证、刷新、撤销、多租户支持
  • Security: 加密解密、数据脱敏、密码验证

分布式服务

  • Consul: 服务注册发现、健康检查、配置管理、KV 存储
  • YARP: API 网关、路由配置、负载均衡、认证转发
  • gRPC: 服务端实现、客户端调用、流式传输
  • Http: 重试策略、熔断降级、请求日志

运维监控

  • OpenTelemetry: 分布式追踪、指标收集、日志关联
  • Logging: 结构化日志、多输出目标、日志过滤
  • HealthChecks: 健康检查端点、自定义检查器
  • Resilience: 重试、熔断、限流、隔离

设计原则

  1. 模块化设计: 每个模块独立封装,按需引用
  2. 依赖注入: 所有服务通过 DI 容器管理
  3. 配置驱动: 通过配置文件灵活调整行为
  4. 接口抽象: 面向接口编程,便于测试和替换
  5. 可扩展性: 支持自定义实现和扩展

版本说明

版本 说明
1.0.0 初始版本
1.1.0 添加 Microsoft.Extensions.AI 封装,完善文档

依赖关系

Healnet.Infrastructure
├── Healnet.Core          (核心模块)
├── Healnet.Common        (通用工具)
├── MongoDB.Driver        (MongoDB 驱动)
├── StackExchange.Redis   (Redis 驱动)
├── RabbitMQ.Client       (RabbitMQ 驱动)
├── Microsoft.IdentityModel.Tokens (JWT)
├── Consul                (服务发现)
├── YARP                  (API 网关)
├── Grpc.Net.Client       (gRPC 客户端)
├── OpenTelemetry         (可观测性)
└── SqlSugarCore          (ORM)

许可证

MIT License

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.

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
3.1.0 46 7/24/2026
3.0.1 54 7/23/2026
3.0.0 50 7/16/2026
2.0.7 59 7/10/2026
2.0.5 62 7/8/2026
2.0.3 67 6/30/2026
2.0.1 67 6/30/2026
2.0.0 66 6/29/2026
1.7.3 59 6/29/2026
1.7.2 64 6/25/2026
1.7.1 61 6/25/2026
1.7.0 65 6/25/2026
1.6.0 76 6/24/2026
1.5.0 63 6/16/2026
1.4.0 62 6/15/2026
1.3.0 78 5/29/2026
1.1.1 68 5/25/2026
1.1.0 70 5/22/2026
1.0.19 70 5/20/2026
1.0.18 64 5/20/2026
Loading failed

新增 Microsoft.Extensions.AI 支持,提供标准化的 AI 抽象层,支持多 AI 提供商切换;新增 ClickHouse 列式数据库支持,提供高性能 OLAP 查询和批量数据操作功能