Files
threshold/internal/snapshot/snapshot.go
shadowdaoandClaude Sonnet 5.5 962d708fdd Rename Go module paths to repo.anhonesthost.net/CyberCoveLLC/threshold
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>
2026-10-12 10:33:41 -07:00

39 lines
1.1 KiB
Go

// Copyright IBM Corp. 2020, 2026
// SPDX-License-Identifier: BUSL-1.1
package snapshot
import (
"context"
"fmt"
"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 snapshot job with the provided scheduler.
func RegisterJob(ctx context.Context, s *scheduler.Scheduler, r db.Reader, w db.Writer) error {
const op = "snapshot.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())
}
snapshotJob, err := newSnapshotJob(ctx, r, w)
if err != nil {
return fmt.Errorf("error creating snapshot job: %w", err)
}
if err := s.RegisterJob(ctx, snapshotJob); err != nil {
return errors.Wrap(ctx, err, op)
}
return nil
}