Initial commit

This commit is contained in:
2026-01-28 20:44:34 +08:00
commit 500e8b74a7
236 changed files with 29886 additions and 0 deletions

39
internal/task/cleaner.go Normal file
View File

@@ -0,0 +1,39 @@
package task
import (
"FileRelay/internal/service"
"context"
"log/slog"
"time"
)
type Cleaner struct {
batchService *service.BatchService
}
func NewCleaner() *Cleaner {
return &Cleaner{
batchService: service.NewBatchService(),
}
}
func (c *Cleaner) Start(ctx context.Context) {
ticker := time.NewTicker(1 * time.Hour)
defer ticker.Stop()
for {
select {
case <-ctx.Done():
return
case <-ticker.C:
c.Clean()
}
}
}
func (c *Cleaner) Clean() {
slog.Info("Running cleanup task")
if err := c.batchService.Cleanup(context.Background()); err != nil {
slog.Error("Error during cleanup", "error", err)
}
}