2021-05-06 14:54:10 -07:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-02-02 17:15:17 -08:00
|
|
|
|
2021-05-06 14:54:10 -07:00
|
|
|
package job
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/hashicorp/boundary/internal/scheduler/job/store"
|
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
|
|
|
)
|
|
|
|
|
|
2024-10-25 14:21:26 +01:00
|
|
|
// Run represents an instance of a job that is either actively running or has failed in some way.
|
2021-05-06 14:54:10 -07:00
|
|
|
type Run struct {
|
|
|
|
|
*store.JobRun
|
|
|
|
|
tableName string `gorm:"-"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (j *Run) clone() *Run {
|
|
|
|
|
cp := proto.Clone(j.JobRun)
|
|
|
|
|
return &Run{
|
|
|
|
|
JobRun: cp.(*store.JobRun),
|
|
|
|
|
tableName: j.tableName,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func allocRun() *Run {
|
|
|
|
|
return &Run{
|
|
|
|
|
JobRun: &store.JobRun{},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TableName returns the table name for the job run.
|
|
|
|
|
func (j *Run) TableName() string {
|
|
|
|
|
if j.tableName != "" {
|
|
|
|
|
return j.tableName
|
|
|
|
|
}
|
|
|
|
|
return "job_run"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SetTableName sets the table name. If the caller attempts to
|
|
|
|
|
// set the name to "" the name will be reset to the default name "job_run".
|
|
|
|
|
func (j *Run) SetTableName(n string) {
|
|
|
|
|
j.tableName = n
|
|
|
|
|
}
|