fix: run jobs at interval instead of specific time (#585)

This commit is contained in:
Alessandro (Ale) Segala
2025-05-29 08:15:35 -07:00
committed by GitHub
parent 3d402fc0ca
commit 6d6dc6646a
7 changed files with 105 additions and 46 deletions

View File

@@ -2,6 +2,9 @@ package job
import (
"context"
"time"
"github.com/go-co-op/gocron/v2"
"github.com/pocket-id/pocket-id/backend/internal/service"
)
@@ -15,7 +18,7 @@ func (s *Scheduler) RegisterLdapJobs(ctx context.Context, ldapService *service.L
jobs := &LdapJobs{ldapService: ldapService, appConfigService: appConfigService}
// Register the job to run every hour
return s.registerJob(ctx, "SyncLdap", "0 * * * *", jobs.syncLdap, true)
return s.registerJob(ctx, "SyncLdap", gocron.DurationJob(time.Hour), jobs.syncLdap, true)
}
func (j *LdapJobs) syncLdap(ctx context.Context) error {