Documentation ¶
Index ¶
- func GetStateResolver(db Store) *jobutils.StateResolver
- func StopJob(ctx context.Context, db Store, jobID string, reason string, userRequested bool) ([]model.ExecutionState, error)
- type ErrExecutionAlreadyExists
- type ErrExecutionAlreadyTerminal
- type ErrExecutionNotFound
- type ErrInvalidExecutionState
- type ErrInvalidExecutionVersion
- type ErrInvalidJobState
- type ErrInvalidJobVersion
- type ErrJobAlreadyExists
- type ErrJobAlreadyTerminal
- type ErrJobNotFound
- type JobHistoryFilterOptions
- type JobQuery
- type Store
- type UpdateExecutionCondition
- type UpdateExecutionRequest
- type UpdateJobCondition
- type UpdateJobStateRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetStateResolver ¶
func GetStateResolver(db Store) *jobutils.StateResolver
Types ¶
type ErrExecutionAlreadyExists ¶
type ErrExecutionAlreadyExists struct {
ExecutionID model.ExecutionID
}
ErrExecutionAlreadyExists is returned when an job already exists
func NewErrExecutionAlreadyExists ¶
func NewErrExecutionAlreadyExists(id model.ExecutionID) ErrExecutionAlreadyExists
func (ErrExecutionAlreadyExists) Error ¶
func (e ErrExecutionAlreadyExists) Error() string
type ErrExecutionAlreadyTerminal ¶
type ErrExecutionAlreadyTerminal struct { ExecutionID model.ExecutionID Actual model.ExecutionStateType NewState model.ExecutionStateType }
ErrExecutionAlreadyTerminal is returned when an execution is already in terminal state and cannot be updated.
func NewErrExecutionAlreadyTerminal ¶
func NewErrExecutionAlreadyTerminal( id model.ExecutionID, actual model.ExecutionStateType, newState model.ExecutionStateType) ErrExecutionAlreadyTerminal
func (ErrExecutionAlreadyTerminal) Error ¶
func (e ErrExecutionAlreadyTerminal) Error() string
type ErrExecutionNotFound ¶
type ErrExecutionNotFound struct {
ExecutionID model.ExecutionID
}
ErrExecutionNotFound is returned when an job already exists
func NewErrExecutionNotFound ¶
func NewErrExecutionNotFound(id model.ExecutionID) ErrExecutionNotFound
func (ErrExecutionNotFound) Error ¶
func (e ErrExecutionNotFound) Error() string
type ErrInvalidExecutionState ¶
type ErrInvalidExecutionState struct { ExecutionID model.ExecutionID Actual model.ExecutionStateType Expected model.ExecutionStateType }
ErrInvalidExecutionState is returned when an execution is in an invalid state.
func NewErrInvalidExecutionState ¶
func NewErrInvalidExecutionState( id model.ExecutionID, actual model.ExecutionStateType, expected model.ExecutionStateType) ErrInvalidExecutionState
func (ErrInvalidExecutionState) Error ¶
func (e ErrInvalidExecutionState) Error() string
type ErrInvalidExecutionVersion ¶
type ErrInvalidExecutionVersion struct { ExecutionID model.ExecutionID Actual int Expected int }
ErrInvalidExecutionVersion is returned when an execution has an invalid version.
func NewErrInvalidExecutionVersion ¶
func NewErrInvalidExecutionVersion(id model.ExecutionID, actual int, expected int) ErrInvalidExecutionVersion
func (ErrInvalidExecutionVersion) Error ¶
func (e ErrInvalidExecutionVersion) Error() string
type ErrInvalidJobState ¶
type ErrInvalidJobState struct { JobID string Actual model.JobStateType Expected model.JobStateType }
ErrInvalidJobState is returned when an job is in an invalid state.
func NewErrInvalidJobState ¶
func NewErrInvalidJobState(id string, actual model.JobStateType, expected model.JobStateType) ErrInvalidJobState
func (ErrInvalidJobState) Error ¶
func (e ErrInvalidJobState) Error() string
type ErrInvalidJobVersion ¶
ErrInvalidJobVersion is returned when an job has an invalid version.
func NewErrInvalidJobVersion ¶
func NewErrInvalidJobVersion(id string, actual int, expected int) ErrInvalidJobVersion
func (ErrInvalidJobVersion) Error ¶
func (e ErrInvalidJobVersion) Error() string
type ErrJobAlreadyExists ¶
type ErrJobAlreadyExists struct {
JobID string
}
ErrJobAlreadyExists is returned when an job already exists
func NewErrJobAlreadyExists ¶
func NewErrJobAlreadyExists(id string) ErrJobAlreadyExists
func (ErrJobAlreadyExists) Error ¶
func (e ErrJobAlreadyExists) Error() string
type ErrJobAlreadyTerminal ¶
type ErrJobAlreadyTerminal struct { JobID string Actual model.JobStateType NewState model.JobStateType }
ErrJobAlreadyTerminal is returned when an job is already in terminal state and cannot be updated.
func NewErrJobAlreadyTerminal ¶
func NewErrJobAlreadyTerminal(id string, actual model.JobStateType, newState model.JobStateType) ErrJobAlreadyTerminal
func (ErrJobAlreadyTerminal) Error ¶
func (e ErrJobAlreadyTerminal) Error() string
type ErrJobNotFound ¶
type ErrJobNotFound struct {
JobID string
}
ErrJobNotFound is returned when the job is not found
func NewErrJobNotFound ¶
func NewErrJobNotFound(id string) ErrJobNotFound
func (ErrJobNotFound) Error ¶
func (e ErrJobNotFound) Error() string
type JobHistoryFilterOptions ¶ added in v0.3.26
type JobQuery ¶
type JobQuery struct { ID string `json:"id"` ClientID string `json:"clientID"` IncludeTags []model.IncludedTag `json:"include_tags"` ExcludeTags []model.ExcludedTag `json:"exclude_tags"` Limit int `json:"limit"` Offset int `json:"offset"` ReturnAll bool `json:"return_all"` SortBy string `json:"sort_by"` SortReverse bool `json:"sort_reverse"` }
type Store ¶
type Store interface { GetJob(ctx context.Context, id string) (model.Job, error) GetJobs(ctx context.Context, query JobQuery) ([]model.Job, error) GetJobState(ctx context.Context, jobID string) (model.JobState, error) GetInProgressJobs(ctx context.Context) ([]model.JobWithInfo, error) GetJobHistory(ctx context.Context, jobID string, options JobHistoryFilterOptions) ([]model.JobHistory, error) GetJobsCount(ctx context.Context, query JobQuery) (int, error) CreateJob(ctx context.Context, j model.Job) error // UpdateJobState updates the Job state UpdateJobState(ctx context.Context, request UpdateJobStateRequest) error // CreateExecution creates a new execution for a given job CreateExecution(ctx context.Context, execution model.ExecutionState) error // UpdateExecution updates the Job state UpdateExecution(ctx context.Context, request UpdateExecutionRequest) error }
A Store will persist jobs and their state to the underlying storage. It also gives an efficient way to retrieve jobs using queries.
type UpdateExecutionCondition ¶
type UpdateExecutionCondition struct { ExpectedState model.ExecutionStateType ExpectedVersion int UnexpectedStates []model.ExecutionStateType }
func (UpdateExecutionCondition) Validate ¶
func (condition UpdateExecutionCondition) Validate(execution model.ExecutionState) error
Validate checks if the condition matches the given execution
type UpdateExecutionRequest ¶
type UpdateExecutionRequest struct { ExecutionID model.ExecutionID Condition UpdateExecutionCondition NewValues model.ExecutionState Comment string }
type UpdateJobCondition ¶
type UpdateJobCondition struct { ExpectedState model.JobStateType UnexpectedStates []model.JobStateType ExpectedVersion int }
type UpdateJobStateRequest ¶
type UpdateJobStateRequest struct { JobID string Condition UpdateJobCondition NewState model.JobStateType Comment string }