mirror of https://github.com/hashicorp/boundary
feat: license util config (#3248)
* feat: license util config * address comments * introduce census job * add job * fix import groups * remove pointerspull/3251/head
parent
7bdbe8ab8e
commit
9ae2bdfae6
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (c) HashiCorp, Inc.
|
||||||
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
|
package census
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"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 census job with the provided scheduler.
|
||||||
|
func RegisterJob(ctx context.Context, s *scheduler.Scheduler, optOut bool, r db.Reader, w db.Writer) error {
|
||||||
|
const op = "census.RegisterJob"
|
||||||
|
if s == nil {
|
||||||
|
return errors.New(ctx, errors.InvalidParameter, "nil scheduler", op, errors.WithoutEvent())
|
||||||
|
}
|
||||||
|
if util.IsNil(r) {
|
||||||
|
return errors.New(ctx, errors.Internal, "nil DB reader", op, errors.WithoutEvent())
|
||||||
|
}
|
||||||
|
if util.IsNil(w) {
|
||||||
|
return errors.New(ctx, errors.Internal, "nil DB writer", op, errors.WithoutEvent())
|
||||||
|
}
|
||||||
|
if util.IsNil(optOut) {
|
||||||
|
return errors.New(ctx, errors.Internal, "nil opt out value", op, errors.WithoutEvent())
|
||||||
|
}
|
||||||
|
|
||||||
|
censusJob, err := NewCensusJobFn(ctx, optOut, r, w)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error creating census job: %w", err)
|
||||||
|
}
|
||||||
|
if err := s.RegisterJob(ctx, censusJob); err != nil {
|
||||||
|
return errors.Wrap(ctx, err, op)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Loading…
Reference in new issue