Skip to content

Commit

Permalink
fix: centrum housekeepr cron schedules for cleanups and co
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Trost <[email protected]>
  • Loading branch information
galexrt committed Dec 5, 2024
1 parent 546b389 commit 4369ff9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
22 changes: 14 additions & 8 deletions gen/go/proto/services/centrum/centrummanager/housekeeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"go.uber.org/fx"
"go.uber.org/multierr"
"go.uber.org/zap"
"google.golang.org/protobuf/types/known/durationpb"
)

const (
Expand Down Expand Up @@ -93,38 +94,43 @@ func NewHousekeeper(p HousekeeperParams) *Housekeeper {
if err := p.Cron.RegisterCronjob(ctxStartup, &cron.Cronjob{
Name: "centrum.manager_housekeeper.dispatch_assignment_expiration",
Schedule: "@everysecond", // Every second
Timeout: durationpb.New(3 * time.Second),
}); err != nil {
return err
}

p.CronHandlers.Add("centrum.manager_housekeeper.dispatch_deduplication", s.runDispatchDeduplication)
if err := p.Cron.RegisterCronjob(ctxStartup, &cron.Cronjob{
Name: "centrum.manager_housekeeper.dispatch_deduplication",
Schedule: "*/2 * * * * *", // Every 2 seconds
Schedule: "*/2 * * * * * *", // Every 2 seconds
Timeout: durationpb.New(5 * time.Second),
}); err != nil {
return err
}

p.CronHandlers.Add("centrum.manager_housekeeper.cleanup_units", s.runCleanupUnits)
if err := p.Cron.RegisterCronjob(ctxStartup, &cron.Cronjob{
Name: "centrum.manager_housekeeper.cleanup_units",
Schedule: "*/5 * * * * *", // Every 5 seconds
Schedule: "*/5 * * * * * *", // Every 5 seconds
Timeout: durationpb.New(10 * time.Second),
}); err != nil {
return err
}

p.CronHandlers.Add("centrum.manager_housekeeper.delete_old_dispatches", s.runDeleteOldDispatches)
p.CronHandlers.Add("centrum.manager_housekeeper.cancel_old_dispatches", s.runCancelOldDispatches)
if err := p.Cron.RegisterCronjob(ctxStartup, &cron.Cronjob{
Name: "centrum.manager_housekeeper.delete_old_dispatches",
Schedule: "*/4 * * * *", // Every 4 minutes
Name: "centrum.manager_housekeeper.cancel_old_dispatches",
Schedule: "*/15 * * * * * *", // Every 15 seconds
Timeout: durationpb.New(20 * time.Second),
}); err != nil {
return err
}

p.CronHandlers.Add("centrum.manager_housekeeper.cancel_old_dispatches", s.runCancelOldDispatches)
p.CronHandlers.Add("centrum.manager_housekeeper.delete_old_dispatches", s.runDeleteOldDispatches)
if err := p.Cron.RegisterCronjob(ctxStartup, &cron.Cronjob{
Name: "centrum.manager_housekeeper.cancel_old_dispatches",
Schedule: "*/15 * * * * *", // Every 15 seconds
Name: "centrum.manager_housekeeper.delete_old_dispatches",
Schedule: "*/4 * * * *", // Every 4 minutes
Timeout: durationpb.New(15 * time.Second),
}); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/housekeeper/housekeeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func New(p Params) *Housekeeper {
p.LC.Append(fx.StartHook(func(ctx context.Context) error {
if err := p.Cron.RegisterCronjob(ctx, &cron.Cronjob{
Name: "housekeeper.run",
Schedule: "*/20 * * * * * *", // Every 5 minutes
Schedule: "@5minutes", // Every 5 minutes
}); err != nil {
return err
}
Expand Down

0 comments on commit 4369ff9

Please sign in to comment.