You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
boundary/internal/snapshot/snapshot_job.go

70 lines
1.8 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// Copyright IBM Corp. 2020, 2025
// SPDX-License-Identifier: BUSL-1.1
package snapshot
import (
"context"
"time"
"github.com/hashicorp/boundary/internal/db"
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/scheduler"
)
var runFn = runInternal
type snapshotJob struct {
r db.Reader
w db.Writer
}
func newSnapshotJob(ctx context.Context, r db.Reader, w db.Writer) (*snapshotJob, error) {
const op = "snapshotJob.newSnapshotJob"
switch {
case r == nil:
return nil, errors.New(ctx, errors.InvalidParameter, op, "missing db.Reader")
case w == nil:
return nil, errors.New(ctx, errors.InvalidParameter, op, "missing db.Writer")
}
return &snapshotJob{
r: r,
w: w,
}, nil
}
// Status reports the jobs current status.
func (c *snapshotJob) Status() scheduler.JobStatus {
return scheduler.JobStatus{}
}
// Run performs the required work depending on the implementation.
// The context is used to notify the job that it should exit early.
func (c *snapshotJob) Run(ctx context.Context, _ time.Duration) error {
const op = "snapshot.(snapshotJob).Run"
err := runFn(ctx, c)
return err
}
func runInternal(ctx context.Context, c *snapshotJob) error {
return nil
}
// NextRunIn returns the duration until the next job run should be scheduled.
// We report as ready immediately after a successful run. This doesn't mean that
// this job will run immediately, only about as often as the configured scheduler interval.
func (c *snapshotJob) NextRunIn(_ context.Context) (time.Duration, error) {
return 0, nil
}
// Name is the unique name of the job.
func (c *snapshotJob) Name() string {
return "job_run_snapshot"
}
// Description is the human-readable description of the job.
func (c *snapshotJob) Description() string {
return "Creates and stores a snapshot from sessions warehouse to snapshot table"
}