这是基于vue-vben-admin 模板适用于abp Vnext的前端管理项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

8.9 KiB

平台服务部署

**本文档引用的文件** - [PlatformManagementHttpApiHostModule.cs](file://aspnet-core\services\LY.MicroService.PlatformManagement.HttpApi.Host\PlatformManagementHttpApiHostModule.cs) - [Program.cs](file://aspnet-core\services\LY.MicroService.PlatformManagement.HttpApi.Host\Program.cs) - [appsettings.json](file://aspnet-core\services\LY.MicroService.PlatformManagement.HttpApi.Host\appsettings.json) - [PlatformDbMigrationService.cs](file://aspnet-core\migrations\LY.MicroService.Platform.EntityFrameworkCore\PlatformDbMigrationService.cs) - [PlatformDbMigratorHostedService.cs](file://aspnet-core\migrations\LY.MicroService.Platform.DbMigrator\PlatformDbMigratorHostedService.cs) - [Tenant.cs](file://aspnet-core\modules\saas\LINGYUN.Abp.Saas.Domain\LINGYUN\Abp\Saas\Tenants\Tenant.cs) - [TenantConnectionString.cs](file://aspnet-core\modules\saas\LINGYUN.Abp.Saas.Domain\LINGYUN\Abp\Saas\Tenants\TenantConnectionString.cs) - [ITenantAppService.cs](file://aspnet-core\modules\saas\LINGYUN.Abp.Saas.Application.Contracts\LINGYUN\Abp\Saas\Tenants\ITenantAppService.cs) - [TenantCreateDto.cs](file://aspnet-core\modules\saas\LINGYUN.Abp.Saas.Application.Contracts\LINGYUN\Abp\Saas\Tenants\Dto\TenantCreateDto.cs) - [TenantConnectionStringSetInput.cs](file://aspnet-core\modules\saas\LINGYUN.Abp.Saas.Application.Contracts\LINGYUN\Abp\Saas\Tenants\Dto\TenantConnectionStringSetInput.cs) - [TenantStore.cs](file://aspnet-core\modules\saas\LINGYUN.Abp.MultiTenancy.Saas\LINGYUN\Abp\MultiTenancy\Saas\TenantStore.cs)

目录

  1. 简介
  2. 项目结构
  3. 核心组件
  4. 架构概述
  5. 详细组件分析
  6. 依赖分析
  7. 性能考虑
  8. 故障排除指南
  9. 结论

简介

本文档详细说明了平台服务的部署配置,涵盖多租户支持的数据库配置、租户初始化流程、平台级配置管理,以及与其他核心服务(如认证、用户管理)的集成配置。文档还提供了平台服务特有的部署考虑,包括租户数据隔离策略、跨租户通信配置、平台级事件总线集成,以及服务的高可用性配置和灾难恢复方案。

项目结构

平台服务位于 aspnet-core 目录下的 modules/platformservices/LY.MicroService.PlatformManagement.HttpApi.Host 中。服务的数据库迁移模块位于 migrations/LY.MicroService.Platform.DbMigratormigrations/LY.MicroService.Platform.EntityFrameworkCore。平台服务的宿主模块是 LY.MicroService.PlatformManagement.HttpApi.Host,它集成了平台应用、实体框架核心、OSS管理、通知、身份管理等多个模块。

graph TB
subgraph "平台服务模块"
PlatformApp[平台应用模块]
PlatformDomain[平台领域模块]
PlatformEF[平台EF核心模块]
PlatformHttpApi[平台HTTP API模块]
end
subgraph "平台服务宿主"
Host[平台管理HTTP API宿主]
DbMigrator[平台数据库迁移器]
end
subgraph "核心依赖"
Saas[多租户模块]
Identity[身份管理模块]
Oss[OSS管理模块]
Notification[通知模块]
end
PlatformApp --> PlatformDomain
PlatformApp --> PlatformEF
PlatformApp --> PlatformHttpApi
Host --> PlatformApp
Host --> Saas
Host --> Identity
Host --> Oss
Host --> Notification
DbMigrator --> PlatformEF
DbMigrator --> Saas

图源

  • PlatformManagementHttpApiHostModule.cs
  • LY.MicroService.Platform.EntityFrameworkCore.csproj

本节来源

  • PlatformManagementHttpApiHostModule.cs
  • LY.MicroService.Platform.EntityFrameworkCore.csproj

核心组件

平台服务的核心组件包括平台应用模块、平台领域模块、平台HTTP API模块和平台实体框架核心模块。这些模块共同提供了平台级的功能,如配置管理、多租户支持、OSS管理、通知服务等。平台服务通过 PlatformManagementHttpApiHost 宿主模块启动,并集成了一系列中间件和第三方服务,如Serilog日志、CAP事件总线、SkyWalking监控等。

本节来源

  • PlatformManagementHttpApiHostModule.cs
  • PlatformApplicationModule.cs

架构概述

平台服务采用微服务架构,基于ABP框架构建。服务通过 PlatformManagementHttpApiHost 模块启动,集成了多租户、身份认证、OSS管理、通知、日志、监控等多个功能模块。服务使用Entity Framework Core进行数据访问,支持MySQL、PostgreSQL等多种数据库。平台服务通过CAP事件总线与其他服务进行异步通信,确保系统的松耦合和高可用性。

graph TD
Client[客户端] --> Gateway[API网关]
Gateway --> Platform[平台服务]
Platform --> DB[(数据库)]
Platform --> Redis[(Redis)]
Platform --> Minio[(MinIO)]
Platform --> CAP[(CAP事件总线)]
Platform --> SkyWalking[(SkyWalking)]
Platform --> Elasticsearch[(Elasticsearch)]
CAP --> OtherServices[其他微服务]
SkyWalking --> Monitoring[监控系统]
Elasticsearch --> Logging[日志系统]

图源

  • PlatformManagementHttpApiHostModule.cs
  • appsettings.json

详细组件分析

平台服务宿主模块分析

平台服务宿主模块 PlatformManagementHttpApiHostModule 是服务的入口点,负责配置和初始化所有依赖模块。模块通过 DependsOn 特性声明了对多个功能模块的依赖,包括多租户、身份管理、OSS管理、通知、日志、监控等。在 ConfigureServices 方法中,模块配置了虚拟文件系统、缓存、身份认证、跨域、Swagger等服务。

对象导向组件

classDiagram
class PlatformManagementHttpApiHostModule {
+PreConfigureServices(context)
+ConfigureServices(context)
+OnPostApplicationInitialization(context)
+OnApplicationInitialization(context)
}
class AbpModule {
<<abstract>>
}
PlatformManagementHttpApiHostModule --|> AbpModule : 继承

图源

  • PlatformManagementHttpApiHostModule.cs

API/服务组件

sequenceDiagram
participant Client as "客户端"
participant Gateway as "API网关"
participant Platform as "平台服务"
participant DB as "数据库"
participant CAP as "CAP事件总线"
Client->>Gateway : HTTP请求
Gateway->>Platform : 转发请求
Platform->>Platform : 认证与授权
Platform->>DB : 数据访问
Platform->>CAP : 发布事件
CAP-->>Platform : 事件处理
Platform-->>Gateway : 响应
Gateway-->>Client : 返回结果

图源

  • PlatformManagementHttpApiHostModule.cs
  • PlatformDbMigrationService.cs

多租户与数据库配置分析

平台服务通过ABP框架的多租户功能支持多租户架构。租户信息存储在 Tenant 实体中,每个租户可以配置独立的数据库连接字符串。租户的连接字符串通过 TenantConnectionString 实体管理,支持多个命名的连接字符串。

对象导向组件

classDiagram
class Tenant {
+Guid Id
+string Name
+string NormalizedName
+bool IsActive
+DateTime? EnableTime
+DateTime? DisableTime
+Guid? EditionId
+Collection~TenantConnectionString~ ConnectionStrings
+SetDefaultConnectionString(connectionString)
+SetConnectionString(name, connectionString)
+FindConnectionString(name)
}
class TenantConnectionString {
+Guid TenantId
+string Name
+string Value
+SetValue(value)
}
Tenant "1" -- "0..*" TenantConnectionString : 包含

图源

  • Tenant.cs
  • TenantConnectionString.cs

租户初始化流程

flowchart TD
    Start([开始]) --> CheckTenant["检查租户是否存在"]
    CheckTenant --> TenantExists{"租户存在?"}
    TenantExists -->|否| CreateTenant["