reap_sync_orphans_job.go 693 B

123456789101112131415161718192021222324252627
  1. package job
  2. import (
  3. "github.com/mhsanaei/3x-ui/v3/internal/logger"
  4. "github.com/mhsanaei/3x-ui/v3/internal/web/service"
  5. )
  6. // ReapSyncOrphansJob hard-deletes the clients the node-snapshot sweep only
  7. // soft-orphaned, once enough clean merges have agreed they are really gone.
  8. type ReapSyncOrphansJob struct {
  9. clientService service.ClientService
  10. }
  11. func NewReapSyncOrphansJob() *ReapSyncOrphansJob {
  12. return new(ReapSyncOrphansJob)
  13. }
  14. func (j *ReapSyncOrphansJob) Run() {
  15. reaped, err := j.clientService.ReapSyncOrphans()
  16. if err != nil {
  17. logger.Warning("reap sync orphans failed:", err)
  18. return
  19. }
  20. if reaped > 0 {
  21. logger.Infof("reap sync orphans: removed %d client(s)", reaped)
  22. }
  23. }