Files
threshold/internal/scheduler/job/job.go
T
Louis Ruch feb5d7385d Louis job scheduler (#1197)
* Adds job repo
* Adds scheduler
* Adds plugin table which is a place holder for future expansion of the scheduler. Currently all jobs that are created are linked to the pi_system plugin which are jobs that are held in a local registeredJobs map populated at controller startup.
2021-05-06 14:54:10 -07:00

42 lines
915 B
Go

package job
import (
"github.com/hashicorp/boundary/internal/scheduler/job/store"
"google.golang.org/protobuf/proto"
)
// Job represents work that should be run at a predetermined time and needs to be synchronized
// across servers to ensure that one and only one instance of a job is running at any given time.
type Job struct {
*store.Job
tableName string `gorm:"-"`
}
func (j *Job) clone() *Job {
cp := proto.Clone(j.Job)
return &Job{
Job: cp.(*store.Job),
tableName: j.tableName,
}
}
func allocJob() *Job {
return &Job{
Job: &store.Job{},
}
}
// TableName returns the table name for the job.
func (j *Job) TableName() string {
if j.tableName != "" {
return j.tableName
}
return "job"
}
// SetTableName sets the table name. If the caller attempts to
// set the name to "" the name will be reset to the default name "job".
func (j *Job) SetTableName(n string) {
j.tableName = n
}