Version: 0.9.73.dev.260505

后端:
1.阶段 5 course 服务边界落地
- 新增 cmd/course 独立进程入口,落地 services/course dao/rpc/sv
- 新增 gateway/client/course、shared/contracts/course 和 shared/ports course port
- 将 /api/v1/course/* HTTP 门面切到 course zrpc,gateway 只保留鉴权、限流、幂等、文件读取和响应透传
- 保留 course 迁移期直写 schedule_events / schedules 权限,维持课程导入两个表同事务写入语义
- 为 course parse-image 补 bytes RPC 契约和 gRPC 消息大小配置,兼容课表图片上传
- 补充 course.rpc 示例配置与阶段 5 文档基线、切流点、残留依赖和 smoke 记录
This commit is contained in:
Losita
2026-05-05 12:07:31 +08:00
parent 7ed8adf8d1
commit fd327f845b
21 changed files with 1882 additions and 42 deletions

View File

@@ -15,6 +15,7 @@ import (
"github.com/LoveLosita/smartflow/backend/dao"
"github.com/LoveLosita/smartflow/backend/gateway/api"
gatewayactivescheduler "github.com/LoveLosita/smartflow/backend/gateway/client/activescheduler"
gatewaycourse "github.com/LoveLosita/smartflow/backend/gateway/client/course"
gatewaynotification "github.com/LoveLosita/smartflow/backend/gateway/client/notification"
gatewayschedule "github.com/LoveLosita/smartflow/backend/gateway/client/schedule"
gatewaytask "github.com/LoveLosita/smartflow/backend/gateway/client/task"
@@ -195,7 +196,6 @@ func buildRuntime(ctx context.Context) (*appRuntime, error) {
agentCacheRepo := dao.NewAgentCache(rdb)
_ = db.Use(middleware.NewGormCachePlugin(cacheRepo))
taskRepo := dao.NewTaskDAO(db)
courseRepo := dao.NewCourseDAO(db)
taskClassRepo := dao.NewTaskClassDAO(db)
scheduleRepo := dao.NewScheduleDAO(db)
manager := dao.NewManager(db)
@@ -248,6 +248,15 @@ func buildRuntime(ctx context.Context) (*appRuntime, error) {
if err != nil {
return nil, fmt.Errorf("failed to initialize task-class zrpc client: %w", err)
}
courseClient, err := gatewaycourse.NewClient(gatewaycourse.ClientConfig{
Endpoints: viper.GetStringSlice("course.rpc.endpoints"),
Target: viper.GetString("course.rpc.target"),
Timeout: viper.GetDuration("course.rpc.timeout"),
MaxImageBytes: viper.GetInt64("courseImport.maxImageBytes"),
})
if err != nil {
return nil, fmt.Errorf("failed to initialize course zrpc client: %w", err)
}
activeSchedulerClient, err := gatewayactivescheduler.NewClient(gatewayactivescheduler.ClientConfig{
Endpoints: viper.GetStringSlice("activeScheduler.rpc.endpoints"),
Target: viper.GetString("activeScheduler.rpc.target"),
@@ -262,7 +271,6 @@ func buildRuntime(ctx context.Context) (*appRuntime, error) {
taskOutboxPublisher := buildTaskOutboxPublisher(outboxRepo)
taskSv := service.NewTaskService(taskRepo, cacheRepo, taskOutboxPublisher)
taskSv.SetActiveScheduleDAO(manager.ActiveSchedule)
courseService := buildCourseService(llmService, courseRepo, scheduleRepo)
scheduleService := service.NewScheduleService(scheduleRepo, taskClassRepo, manager, cacheRepo)
agentService := service.NewAgentServiceWithSchedule(
llmService,
@@ -325,7 +333,7 @@ func buildRuntime(ctx context.Context) (*appRuntime, error) {
return nil, err
}
agentService.SetActiveScheduleSessionRerunFunc(buildActiveScheduleSessionRerunFunc(manager.ActiveSchedule, activeScheduleGraphRunner, activeSchedulePreviewConfirm, activeScheduleFeedbackLocator))
handlers := buildAPIHandlers(taskClient, taskClassClient, courseService, scheduleClient, agentService, memoryModule, activeSchedulerClient, notificationClient)
handlers := buildAPIHandlers(taskClient, taskClassClient, courseClient, scheduleClient, agentService, memoryModule, activeSchedulerClient, notificationClient)
runtime := &appRuntime{
db: db,
@@ -915,7 +923,7 @@ func buildQuickTaskQueryFunc(agentService *service.AgentService) func(ctx contex
func buildAPIHandlers(
taskClient ports.TaskCommandClient,
taskClassClient ports.TaskClassCommandClient,
courseService *service.CourseService,
courseClient ports.CourseCommandClient,
scheduleClient ports.ScheduleCommandClient,
agentService *service.AgentService,
memoryModule *memory.Module,
@@ -925,7 +933,7 @@ func buildAPIHandlers(
return &api.ApiHandlers{
TaskHandler: api.NewTaskHandler(taskClient),
TaskClassHandler: api.NewTaskClassHandler(taskClassClient),
CourseHandler: api.NewCourseHandler(courseService),
CourseHandler: api.NewCourseHandler(courseClient),
ScheduleHandler: api.NewScheduleAPI(scheduleClient),
AgentHandler: api.NewAgentHandler(agentService),
MemoryHandler: api.NewMemoryHandler(memoryModule),