Files
threshold/internal/scheduler/cleaner/cleaner.go
T
Johan Brandhorst-Satzkorn 55259029f1 Add job run cleaner (#2866)
* chore: remove duplicate import

* feat: Add job run cleaner

The new job cleans job runs older than a configured interval.
Configure the job to clean jobs older than 1 minute.
2023-01-31 20:41:33 -05:00

28 lines
750 B
Go

package cleaner
import (
"context"
"github.com/hashicorp/boundary/internal/db"
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/scheduler"
"github.com/hashicorp/boundary/internal/util"
)
// RegisterJob registers the cleaner job with the provided scheduler.
func RegisterJob(ctx context.Context, s *scheduler.Scheduler, w db.Writer) error {
const op = "cleaner.RegisterJob"
if s == nil {
return errors.New(ctx, errors.Internal, "nil scheduler", op, errors.WithoutEvent())
}
if util.IsNil(w) {
return errors.New(ctx, errors.Internal, "nil DB writer", op, errors.WithoutEvent())
}
if err := s.RegisterJob(ctx, newCleanerJob(w)); err != nil {
return errors.Wrap(ctx, err, op)
}
return nil
}