Version: 0.9.71.dev.260504
后端:
1.阶段 5 task 服务边界落地
- 新增 cmd/task 与 services/task/{dao,rpc,sv},承载 task zrpc、tasks 表迁移和 task outbox 消费边界
- 新增 gateway/client/task、shared/contracts/task 和 task port,gateway /api/v1/task/* 切到 task zrpc client
- 将 task.urgency.promote.requested handler / relay / retry loop 迁入 cmd/task,单体 worker 不再消费 task outbox
- 保留单体 Agent 残留 task 查询的 publish-only 写入能力,避免迁移期 task 事件丢失
- active-scheduler task facts / due job scanner 切到 task RPC,并移除启动期 tasks 表依赖检查
- 更新阶段 5 文档,记录 task 切流点、旧实现保留、跨域 DB 依赖缩减和下一轮建议
- 补充 task rpc 示例配置
This commit is contained in:
73
backend/shared/contracts/task/types.go
Normal file
73
backend/shared/contracts/task/types.go
Normal file
@@ -0,0 +1,73 @@
|
||||
package task
|
||||
|
||||
import "time"
|
||||
|
||||
// AddTaskRequest 是 task 服务新增任务的跨进程契约。
|
||||
//
|
||||
// 职责边界:
|
||||
// 1. 只承载 gateway 鉴权后补齐的 user_id 和前端任务字段;
|
||||
// 2. 不承载 HTTP token、幂等键或缓存语义;
|
||||
// 3. 业务校验仍由 task 服务内部完成。
|
||||
type AddTaskRequest struct {
|
||||
UserID int `json:"user_id"`
|
||||
Title string `json:"title"`
|
||||
PriorityGroup int `json:"priority_group"`
|
||||
EstimatedSections int `json:"estimated_sections"`
|
||||
DeadlineAt *time.Time `json:"deadline_at"`
|
||||
}
|
||||
|
||||
type UserRequest struct {
|
||||
UserID int `json:"user_id"`
|
||||
}
|
||||
|
||||
type CompleteTaskRequest struct {
|
||||
UserID int `json:"user_id"`
|
||||
TaskID int `json:"task_id"`
|
||||
}
|
||||
|
||||
type UndoCompleteTaskRequest struct {
|
||||
UserID int `json:"user_id"`
|
||||
TaskID int `json:"task_id"`
|
||||
}
|
||||
|
||||
type DeleteTaskRequest struct {
|
||||
UserID int `json:"user_id"`
|
||||
TaskID int `json:"task_id"`
|
||||
}
|
||||
|
||||
type UpdateTaskRequest struct {
|
||||
UserID int `json:"user_id"`
|
||||
TaskID int `json:"task_id"`
|
||||
Title *string `json:"title"`
|
||||
PriorityGroup *int `json:"priority_group"`
|
||||
DeadlineAt *time.Time `json:"deadline_at"`
|
||||
UrgencyThresholdAt *time.Time `json:"urgency_threshold_at"`
|
||||
}
|
||||
|
||||
type BatchTaskStatusRequest struct {
|
||||
UserID int `json:"user_id"`
|
||||
IDs []int `json:"ids"`
|
||||
}
|
||||
|
||||
type TaskFactRequest struct {
|
||||
UserID int `json:"user_id"`
|
||||
TaskID int `json:"task_id"`
|
||||
Now time.Time `json:"now"`
|
||||
}
|
||||
|
||||
// TaskFact 是 active-scheduler 读取 task_pool 事实时需要的最小快照。
|
||||
type TaskFact struct {
|
||||
ID int `json:"id"`
|
||||
UserID int `json:"user_id"`
|
||||
Title string `json:"title"`
|
||||
Priority int `json:"priority"`
|
||||
IsCompleted bool `json:"is_completed"`
|
||||
DeadlineAt *time.Time `json:"deadline_at,omitempty"`
|
||||
UrgencyThresholdAt *time.Time `json:"urgency_threshold_at,omitempty"`
|
||||
EstimatedSections int `json:"estimated_sections"`
|
||||
}
|
||||
|
||||
type TaskFactResponse struct {
|
||||
Task TaskFact `json:"task"`
|
||||
Found bool `json:"found"`
|
||||
}
|
||||
Reference in New Issue
Block a user