Rename root, api and sdk module paths (imports, go.mod, go_package, ldflags, build scripts, buf configs) and regenerate protobuf/gateway code with the project's pinned toolchain. Wire identifiers unchanged. api gets a local replace for sdk; root/api/sdk require v0.1.0. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
// Copyright IBM Corp. 2020, 2026
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package census
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io"
|
|
|
|
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/db"
|
|
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/errors"
|
|
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/scheduler"
|
|
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/util"
|
|
)
|
|
|
|
// RegisterJob registers the census job with the provided scheduler.
|
|
func RegisterJob(ctx context.Context, s *scheduler.Scheduler, lurEnabled bool, r db.Reader, w db.Writer, randomReader io.Reader) 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())
|
|
}
|
|
|
|
censusJob, err := NewCensusJobFn(ctx, lurEnabled, r, w, randomReader)
|
|
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
|
|
}
|