feat: 优化知识库删除流程,引入异步任务处理重操作;新增ProcessKBDelete方法实现后台清理

This commit is contained in:
wizardchen
2025-12-25 19:33:58 +08:00
committed by lyingbug
parent be1ec4de5d
commit 10f8830c01
5 changed files with 95 additions and 21 deletions
+8
View File
@@ -8,6 +8,7 @@ const (
TypeSummaryGeneration = "summary:generation" // 摘要生成任务
TypeKBClone = "kb:clone" // 知识库复制任务
TypeIndexDelete = "index:delete" // 索引删除任务
TypeKBDelete = "kb:delete" // 知识库删除任务
)
// ExtractChunkPayload represents the extract chunk task payload
@@ -76,6 +77,13 @@ type IndexDeletePayload struct {
EffectiveEngines []RetrieverEngineParams `json:"effective_engines"`
}
// KBDeletePayload represents the knowledge base delete task payload
type KBDeletePayload struct {
TenantID uint64 `json:"tenant_id"`
KnowledgeBaseID string `json:"knowledge_base_id"`
EffectiveEngines []RetrieverEngineParams `json:"effective_engines"`
}
// KBCloneTaskStatus represents the status of a knowledge base clone task
type KBCloneTaskStatus string
@@ -8,6 +8,7 @@ import (
"context"
"github.com/Tencent/WeKnora/internal/types"
"github.com/hibiken/asynq"
)
// KnowledgeBaseService defines the knowledge base service interface
@@ -88,6 +89,14 @@ type KnowledgeBaseService interface {
// Returns:
// - interfaces.KnowledgeBaseRepository: Knowledge base repository
GetRepository() KnowledgeBaseRepository
// ProcessKBDelete handles async knowledge base deletion task
// Parameters:
// - ctx: Context information
// - t: Asynq task containing KBDeletePayload
// Returns:
// - Possible errors during deletion
ProcessKBDelete(ctx context.Context, t *asynq.Task) error
}
// KnowledgeBaseRepository defines the knowledge base repository interface