MCPcopy Create free account
hub / github.com/astercloud/aster / Cleanup

Method Cleanup

pkg/tools/long_running.go:234–252  ·  view source on GitHub ↗

Cleanup 清理已完成的任务 清理指定时间之前完成的任务

(before time.Time)

Source from the content-addressed store, hash-verified

232// Cleanup 清理已完成的任务
233// 清理指定时间之前完成的任务
234func (e *LongRunningExecutor) Cleanup(before time.Time) int {
235 var deleted int
236
237 e.tasks.Range(func(key, value any) bool {
238 status := value.(*TaskStatus)
239
240 // 只清理终态任务
241 if status.State.IsTerminal() && status.EndTime != nil {
242 if status.EndTime.Before(before) {
243 e.tasks.Delete(key)
244 e.cancels.Delete(key)
245 deleted++
246 }
247 }
248 return true
249 })
250
251 return deleted
252}
253
254// UpdateProgress 更新任务进度(供工具内部调用)
255func (e *LongRunningExecutor) UpdateProgress(taskID string, progress float64, metadata map[string]any) error {

Callers 1

cleanupExampleFunction · 0.95

Calls 2

DeleteMethod · 0.65
IsTerminalMethod · 0.45

Tested by

no test coverage detected