jobstore

package
v0.3.25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2023 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetStateResolver

func GetStateResolver(db Store) *jobutils.StateResolver

func StopJob added in v0.3.24

func StopJob(ctx context.Context, db Store, jobID string, reason string, userRequested bool) ([]model.ExecutionState, error)

StopJob a helper function to fail a job and all its executions.

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

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 (ErrExecutionAlreadyTerminal) Error

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 (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

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

type ErrInvalidJobVersion struct {
	JobID    string
	Actual   int
	Expected int
}

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 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) ([]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
}

func (UpdateJobCondition) Validate

func (condition UpdateJobCondition) Validate(jobState model.JobState) error

Validate checks if the condition matches the given job

type UpdateJobStateRequest

type UpdateJobStateRequest struct {
	JobID     string
	Condition UpdateJobCondition
	NewState  model.JobStateType
	Comment   string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL