refactor(cleaner): 移除未使用的存储删除接口
清理任务时不再调用 Storage.DeleteByTask 方法,因为当前 OSS 服务暂未提供删除接口。 从 StorageService 接口和 ossStorage 实现中移除 DeleteByTask 方法,并更新清理逻辑。
This commit is contained in:
@@ -45,7 +45,6 @@ func (c *cleaner) runOnce(ctx context.Context) {
|
|||||||
g.Log().Errorf(ctx, "[cleaner] list expired(downloaded) error: %v", err)
|
g.Log().Errorf(ctx, "[cleaner] list expired(downloaded) error: %v", err)
|
||||||
} else {
|
} else {
|
||||||
for _, t := range expired {
|
for _, t := range expired {
|
||||||
_ = Storage.DeleteByTask(ctx, t)
|
|
||||||
_ = dao.Task.HardDeleteByIDGlobal(ctx, t.Id)
|
_ = dao.Task.HardDeleteByIDGlobal(ctx, t.Id)
|
||||||
}
|
}
|
||||||
g.Log().Infof(ctx, "[cleaner] expired(downloaded) cleaned, count=%d", len(expired))
|
g.Log().Infof(ctx, "[cleaner] expired(downloaded) cleaned, count=%d", len(expired))
|
||||||
@@ -77,13 +76,12 @@ func (c *cleaner) runOnce(ctx context.Context) {
|
|||||||
g.Log().Infof(ctx, "[cleaner] failed retryable cleaned, count=%d", len(retryable))
|
g.Log().Infof(ctx, "[cleaner] failed retryable cleaned, count=%d", len(retryable))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4) 超过重试次数仍失败(state=3)的任务:硬删除 + OSS
|
// 4) 超过重试次数仍失败(state=3)的任务:硬删除
|
||||||
exhausted, err := dao.Task.ListFailedExhaustedGlobal(ctx, 200)
|
exhausted, err := dao.Task.ListFailedExhaustedGlobal(ctx, 200)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
g.Log().Errorf(ctx, "[cleaner] list failed exhausted error: %v", err)
|
g.Log().Errorf(ctx, "[cleaner] list failed exhausted error: %v", err)
|
||||||
} else {
|
} else {
|
||||||
for _, t := range exhausted {
|
for _, t := range exhausted {
|
||||||
_ = Storage.DeleteByTask(ctx, t)
|
|
||||||
_ = dao.Task.HardDeleteByIDGlobal(ctx, t.Id)
|
_ = dao.Task.HardDeleteByIDGlobal(ctx, t.Id)
|
||||||
}
|
}
|
||||||
g.Log().Infof(ctx, "[cleaner] failed exhausted cleaned, count=%d", len(exhausted))
|
g.Log().Infof(ctx, "[cleaner] failed exhausted cleaned, count=%d", len(exhausted))
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import (
|
|||||||
// StorageService 结果存储(OSS/MinIO)抽象
|
// StorageService 结果存储(OSS/MinIO)抽象
|
||||||
type StorageService interface {
|
type StorageService interface {
|
||||||
UploadByTask(ctx context.Context, t *entity.AsynchTask, data []byte, fileExt string, contentType string) (ossURL string, err error)
|
UploadByTask(ctx context.Context, t *entity.AsynchTask, data []byte, fileExt string, contentType string) (ossURL string, err error)
|
||||||
DeleteByTask(ctx context.Context, t *entity.AsynchTask) error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Storage 默认存储实现(优先对接你们的 oss 文件服务;必要时也可以切到 MinIO)
|
// Storage 默认存储实现(优先对接你们的 oss 文件服务;必要时也可以切到 MinIO)
|
||||||
|
|||||||
@@ -68,13 +68,6 @@ func (s *ossStorage) UploadByTask(ctx context.Context, _ *entity.AsynchTask, dat
|
|||||||
return resp.FileURL, nil
|
return resp.FileURL, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ossStorage) DeleteByTask(ctx context.Context, t *entity.AsynchTask) error {
|
|
||||||
// 你说当前 oss 暂时没有删除接口:这里保留方法占位,后续补接口时直接实现
|
|
||||||
_ = ctx
|
|
||||||
_ = t
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// setTaskHeadersToCtx 把任务入库时保存的 header 信息注入 ctx,给 worker 调 OSS 用
|
// setTaskHeadersToCtx 把任务入库时保存的 header 信息注入 ctx,给 worker 调 OSS 用
|
||||||
func setTaskHeadersToCtx(ctx context.Context, headers map[string]string) context.Context {
|
func setTaskHeadersToCtx(ctx context.Context, headers map[string]string) context.Context {
|
||||||
if headers == nil {
|
if headers == nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user