jobstore

package
v1.2.1-rc2 Latest Latest
Warning

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

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

Documentation

Overview

Code generated by MockGen. DO NOT EDIT. Source: types.go

Generated by this command:

mockgen --source types.go --destination mocks.go --package jobstore

Package jobstore is a generated GoMock package.

Index

Constants

View Source
const DefaultWatchChannelSize = 64

Variables

This section is empty.

Functions

This section is empty.

Types

type Envelope added in v1.0.4

type Envelope[T any] struct {
	Body T
	// contains filtered or unexported fields
}

Envelope provides a wrapper around types that can be stored in a jobstore. It takes responsibility for ser/de for the wrapped type, ensuring that

func NewEnvelope added in v1.0.4

func NewEnvelope[T any](options ...Option[T]) *Envelope[T]

func (*Envelope[T]) Copy added in v1.0.4

func (e *Envelope[T]) Copy() *Envelope[T]

func (*Envelope[T]) Deserialize added in v1.0.4

func (e *Envelope[T]) Deserialize(data []byte) (*Envelope[T], error)

func (*Envelope[T]) Serialize added in v1.0.4

func (e *Envelope[T]) Serialize() ([]byte, error)

func (*Envelope[T]) Unwrap added in v1.0.4

func (e *Envelope[T]) Unwrap() T

func (*Envelope[T]) Wrap added in v1.0.4

func (e *Envelope[T]) Wrap(obj T)

type ErrExecutionAlreadyExists

type ErrExecutionAlreadyExists struct {
	ExecutionID string
}

ErrExecutionAlreadyExists is returned when an job already exists

func NewErrExecutionAlreadyExists

func NewErrExecutionAlreadyExists(id string) ErrExecutionAlreadyExists

func (ErrExecutionAlreadyExists) Error

type ErrExecutionAlreadyTerminal

type ErrExecutionAlreadyTerminal struct {
	ExecutionID string
	Actual      models.ExecutionStateType
	NewState    models.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 string
}

ErrExecutionNotFound is returned when an job already exists

func NewErrExecutionNotFound

func NewErrExecutionNotFound(id string) ErrExecutionNotFound

func (ErrExecutionNotFound) Error

func (e ErrExecutionNotFound) Error() string

type ErrInvalidExecutionState

type ErrInvalidExecutionState struct {
	ExecutionID string
	Actual      models.ExecutionStateType
	Expected    []models.ExecutionStateType
}

ErrInvalidExecutionState is returned when an execution is in an invalid state.

func NewErrInvalidExecutionState

func NewErrInvalidExecutionState(
	id string, actual models.ExecutionStateType, expected ...models.ExecutionStateType) ErrInvalidExecutionState

func (ErrInvalidExecutionState) Error

func (e ErrInvalidExecutionState) Error() string

type ErrInvalidExecutionVersion

type ErrInvalidExecutionVersion struct {
	ExecutionID string
	Actual      uint64
	Expected    uint64
}

ErrInvalidExecutionVersion is returned when an execution has an invalid version.

func NewErrInvalidExecutionVersion

func NewErrInvalidExecutionVersion(id string, actual, expected uint64) ErrInvalidExecutionVersion

func (ErrInvalidExecutionVersion) Error

type ErrInvalidJobState

type ErrInvalidJobState struct {
	JobID    string
	Actual   models.JobStateType
	Expected models.JobStateType
}

ErrInvalidJobState is returned when an job is in an invalid state.

func NewErrInvalidJobState

func NewErrInvalidJobState(id string, actual models.JobStateType, expected models.JobStateType) ErrInvalidJobState

func (ErrInvalidJobState) Error

func (e ErrInvalidJobState) Error() string

type ErrInvalidJobVersion

type ErrInvalidJobVersion struct {
	JobID    string
	Actual   uint64
	Expected uint64
}

ErrInvalidJobVersion is returned when an job has an invalid version.

func NewErrInvalidJobVersion

func NewErrInvalidJobVersion(id string, actual, expected uint64) 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   models.JobStateType
	NewState models.JobStateType
}

ErrJobAlreadyTerminal is returned when an job is already in terminal state and cannot be updated.

func NewErrJobAlreadyTerminal

func NewErrJobAlreadyTerminal(id string, actual models.JobStateType, newState models.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 JobHistoryFilterOptions struct {
	Since                 int64  `json:"since"`
	ExcludeExecutionLevel bool   `json:"exclude_execution_level"`
	ExcludeJobLevel       bool   `json:"exclude_job_level"`
	ExecutionID           string `json:"execution_id"`
	NodeID                string `json:"node_id"`
}

type JobQuery

type JobQuery struct {
	ID          string   `json:"id"`
	Namespace   string   `json:"namespace"`
	IncludeTags []string `json:"include_tags"`
	ExcludeTags []string `json:"exclude_tags"`
	Limit       uint32   `json:"limit"`
	Offset      uint32   `json:"offset"`
	ReturnAll   bool     `json:"return_all"`
	SortBy      string   `json:"sort_by"`
	SortReverse bool     `json:"sort_reverse"`
}

type MockStore added in v1.0.4

type MockStore struct {
	// contains filtered or unexported fields
}

MockStore is a mock of Store interface.

func NewMockStore added in v1.0.4

func NewMockStore(ctrl *gomock.Controller) *MockStore

NewMockStore creates a new mock instance.

func (*MockStore) Close added in v1.0.4

func (m *MockStore) Close(ctx context.Context) error

Close mocks base method.

func (*MockStore) CreateEvaluation added in v1.0.4

func (m *MockStore) CreateEvaluation(ctx context.Context, eval models.Evaluation) error

CreateEvaluation mocks base method.

func (*MockStore) CreateExecution added in v1.0.4

func (m *MockStore) CreateExecution(ctx context.Context, execution models.Execution) error

CreateExecution mocks base method.

func (*MockStore) CreateJob added in v1.0.4

func (m *MockStore) CreateJob(ctx context.Context, j models.Job) error

CreateJob mocks base method.

func (*MockStore) DeleteEvaluation added in v1.0.4

func (m *MockStore) DeleteEvaluation(ctx context.Context, id string) error

DeleteEvaluation mocks base method.

func (*MockStore) DeleteJob added in v1.0.4

func (m *MockStore) DeleteJob(ctx context.Context, jobID string) error

DeleteJob mocks base method.

func (*MockStore) EXPECT added in v1.0.4

func (m *MockStore) EXPECT() *MockStoreMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockStore) GetEvaluation added in v1.0.4

func (m *MockStore) GetEvaluation(ctx context.Context, id string) (models.Evaluation, error)

GetEvaluation mocks base method.

func (*MockStore) GetExecutions added in v1.0.4

func (m *MockStore) GetExecutions(ctx context.Context, jobID string) ([]models.Execution, error)

GetExecutions mocks base method.

func (*MockStore) GetInProgressJobs added in v1.0.4

func (m *MockStore) GetInProgressJobs(ctx context.Context) ([]models.Job, error)

GetInProgressJobs mocks base method.

func (*MockStore) GetJob added in v1.0.4

func (m *MockStore) GetJob(ctx context.Context, id string) (models.Job, error)

GetJob mocks base method.

func (*MockStore) GetJobHistory added in v1.0.4

func (m *MockStore) GetJobHistory(ctx context.Context, jobID string, options JobHistoryFilterOptions) ([]models.JobHistory, error)

GetJobHistory mocks base method.

func (*MockStore) GetJobs added in v1.0.4

func (m *MockStore) GetJobs(ctx context.Context, query JobQuery) ([]models.Job, error)

GetJobs mocks base method.

func (*MockStore) UpdateExecution added in v1.0.4

func (m *MockStore) UpdateExecution(ctx context.Context, request UpdateExecutionRequest) error

UpdateExecution mocks base method.

func (*MockStore) UpdateJobState added in v1.0.4

func (m *MockStore) UpdateJobState(ctx context.Context, request UpdateJobStateRequest) error

UpdateJobState mocks base method.

func (*MockStore) Watch added in v1.0.4

func (m *MockStore) Watch(ctx context.Context, types StoreWatcherType, events StoreEventType) chan WatchEvent

Watch mocks base method.

type MockStoreMockRecorder added in v1.0.4

type MockStoreMockRecorder struct {
	// contains filtered or unexported fields
}

MockStoreMockRecorder is the mock recorder for MockStore.

func (*MockStoreMockRecorder) Close added in v1.0.4

func (mr *MockStoreMockRecorder) Close(ctx any) *gomock.Call

Close indicates an expected call of Close.

func (*MockStoreMockRecorder) CreateEvaluation added in v1.0.4

func (mr *MockStoreMockRecorder) CreateEvaluation(ctx, eval any) *gomock.Call

CreateEvaluation indicates an expected call of CreateEvaluation.

func (*MockStoreMockRecorder) CreateExecution added in v1.0.4

func (mr *MockStoreMockRecorder) CreateExecution(ctx, execution any) *gomock.Call

CreateExecution indicates an expected call of CreateExecution.

func (*MockStoreMockRecorder) CreateJob added in v1.0.4

func (mr *MockStoreMockRecorder) CreateJob(ctx, j any) *gomock.Call

CreateJob indicates an expected call of CreateJob.

func (*MockStoreMockRecorder) DeleteEvaluation added in v1.0.4

func (mr *MockStoreMockRecorder) DeleteEvaluation(ctx, id any) *gomock.Call

DeleteEvaluation indicates an expected call of DeleteEvaluation.

func (*MockStoreMockRecorder) DeleteJob added in v1.0.4

func (mr *MockStoreMockRecorder) DeleteJob(ctx, jobID any) *gomock.Call

DeleteJob indicates an expected call of DeleteJob.

func (*MockStoreMockRecorder) GetEvaluation added in v1.0.4

func (mr *MockStoreMockRecorder) GetEvaluation(ctx, id any) *gomock.Call

GetEvaluation indicates an expected call of GetEvaluation.

func (*MockStoreMockRecorder) GetExecutions added in v1.0.4

func (mr *MockStoreMockRecorder) GetExecutions(ctx, jobID any) *gomock.Call

GetExecutions indicates an expected call of GetExecutions.

func (*MockStoreMockRecorder) GetInProgressJobs added in v1.0.4

func (mr *MockStoreMockRecorder) GetInProgressJobs(ctx any) *gomock.Call

GetInProgressJobs indicates an expected call of GetInProgressJobs.

func (*MockStoreMockRecorder) GetJob added in v1.0.4

func (mr *MockStoreMockRecorder) GetJob(ctx, id any) *gomock.Call

GetJob indicates an expected call of GetJob.

func (*MockStoreMockRecorder) GetJobHistory added in v1.0.4

func (mr *MockStoreMockRecorder) GetJobHistory(ctx, jobID, options any) *gomock.Call

GetJobHistory indicates an expected call of GetJobHistory.

func (*MockStoreMockRecorder) GetJobs added in v1.0.4

func (mr *MockStoreMockRecorder) GetJobs(ctx, query any) *gomock.Call

GetJobs indicates an expected call of GetJobs.

func (*MockStoreMockRecorder) UpdateExecution added in v1.0.4

func (mr *MockStoreMockRecorder) UpdateExecution(ctx, request any) *gomock.Call

UpdateExecution indicates an expected call of UpdateExecution.

func (*MockStoreMockRecorder) UpdateJobState added in v1.0.4

func (mr *MockStoreMockRecorder) UpdateJobState(ctx, request any) *gomock.Call

UpdateJobState indicates an expected call of UpdateJobState.

func (*MockStoreMockRecorder) Watch added in v1.0.4

func (mr *MockStoreMockRecorder) Watch(ctx, types, events any) *gomock.Call

Watch indicates an expected call of Watch.

type Option added in v1.0.4

type Option[T any] func(*Envelope[T])

func WithBody added in v1.0.4

func WithBody[T any](body T) Option[T]

func WithMarshaller added in v1.0.4

func WithMarshaller[T any](marshaller marshaller.Marshaller) Option[T]

type Store

type Store interface {
	// Watch returns a channel from which the caller can read specific events
	// as they are transmitted. When called the combination of parameters
	// will determine which events are sent.  Both the StoreWatcherType and
	// StoreEventType parameters can be a bitmask of entries, so to listen
	// for Create and Delete events for Jobs and Executions you would set
	//   types = JobWatcher | ExecutionWatcher
	//   events = CreateEvent | DeleteEvent
	//
	// The structure sent down the channel when one of these events occurs
	// will contain a timestamp, but also the StoreWatcherType and
	// StoreEventType that triggered the event. A json encoded `[]byte`
	// of the related object will also be included in the [WatchEvent].
	Watch(ctx context.Context, types StoreWatcherType, events StoreEventType) chan WatchEvent

	// GetJob returns a job, identified by the id parameter, or an error if
	// it does not exist.
	GetJob(ctx context.Context, id string) (models.Job, error)

	// GetJobs retrieves a slice of jobs defined by the contents of the
	// [JobQuery]. If it fails, it will return an error
	GetJobs(ctx context.Context, query JobQuery) ([]models.Job, error)

	// GetInProgressJobs retrieves all jobs that have a state that can be
	// considered, 'in progress'. Failure generates an error.
	GetInProgressJobs(ctx context.Context) ([]models.Job, error)

	// GetJobHistory retrieves the history for the specified job.  The
	// history returned is filtered by the contents of the provided
	// [JobHistoryFilterOptions].
	GetJobHistory(ctx context.Context, jobID string, options JobHistoryFilterOptions) ([]models.JobHistory, error)

	// CreateJob will create a new job and persist it in the store.
	CreateJob(ctx context.Context, j models.Job) error

	// GetExecutions retrieves all executions for the specified job.
	GetExecutions(ctx context.Context, jobID string) ([]models.Execution, error)

	// UpdateJobState updates the state for the job identified in the
	// [UpdateJobStateRequest].
	UpdateJobState(ctx context.Context, request UpdateJobStateRequest) error

	// CreateExecution creates a new execution
	CreateExecution(ctx context.Context, execution models.Execution) error

	// UpdateExecution updates the execution state according to the values
	// within [UpdateExecutionRequest].
	UpdateExecution(ctx context.Context, request UpdateExecutionRequest) error

	// DeleteJob removes all trace of the provided job from storage
	DeleteJob(ctx context.Context, jobID string) error

	// CreateEvaluation creates a new evaluation
	CreateEvaluation(ctx context.Context, eval models.Evaluation) error

	// GetEvaluation retrieves the specified evaluation
	GetEvaluation(ctx context.Context, id string) (models.Evaluation, error)

	// DeleteEvaluation deletes the specified evaluation
	DeleteEvaluation(ctx context.Context, id string) error

	// Close provides an interface to cleanup any resources in use when the
	// store is no longer required
	Close(ctx context.Context) 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 StoreEventType added in v1.0.4

type StoreEventType int
const (
	CreateEvent StoreEventType = 1 << iota
	UpdateEvent
	DeleteEvent
)

func (StoreEventType) String added in v1.0.4

func (s StoreEventType) String() string

type StoreWatcherType added in v1.0.4

type StoreWatcherType int
const (
	JobWatcher StoreWatcherType = 1 << iota
	ExecutionWatcher
	EvaluationWatcher
)

func (StoreWatcherType) String added in v1.0.4

func (s StoreWatcherType) String() string

type UpdateExecutionCondition

type UpdateExecutionCondition struct {
	ExpectedStates   []models.ExecutionStateType
	ExpectedRevision uint64
	UnexpectedStates []models.ExecutionStateType
}

func (UpdateExecutionCondition) Validate

func (condition UpdateExecutionCondition) Validate(execution models.Execution) error

Validate checks if the condition matches the given execution

type UpdateExecutionRequest

type UpdateExecutionRequest struct {
	ExecutionID string
	Condition   UpdateExecutionCondition
	NewValues   models.Execution
	Comment     string
}

type UpdateJobCondition

type UpdateJobCondition struct {
	ExpectedState    models.JobStateType
	UnexpectedStates []models.JobStateType
	ExpectedRevision uint64
}

func (UpdateJobCondition) Validate

func (condition UpdateJobCondition) Validate(job models.Job) error

Validate checks if the condition matches the given job

type UpdateJobStateRequest

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

type WatchEvent added in v1.0.4

type WatchEvent struct {
	Kind      StoreWatcherType
	Event     StoreEventType
	Object    []byte
	Timestamp int64
}

WatchEvent is the message passed through the watcher whenever a specific event occurs on a specific type, as requested when creating the watcher.

func NewWatchEvent added in v1.0.4

func NewWatchEvent(kind StoreWatcherType, event StoreEventType, object []byte) WatchEvent

type Watcher added in v1.0.4

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher is used by the jobstore to keep a record of parties interested in events happening in the jobstore. This allows for watching of job and execution types (or both), and for create, update and delete events (or any combination).

func NewWatcher added in v1.0.4

func NewWatcher(types StoreWatcherType, events StoreEventType) *Watcher

func (*Watcher) Channel added in v1.0.4

func (w *Watcher) Channel() chan WatchEvent

func (*Watcher) Close added in v1.0.4

func (w *Watcher) Close()

func (*Watcher) IsWatchingEvent added in v1.0.4

func (w *Watcher) IsWatchingEvent(event StoreEventType) bool

func (*Watcher) IsWatchingType added in v1.0.4

func (w *Watcher) IsWatchingType(kind StoreWatcherType) bool

func (*Watcher) WriteEvent added in v1.0.4

func (w *Watcher) WriteEvent(kind StoreWatcherType, event StoreEventType, object []byte, allowBlock bool) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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