store

package
v0.3.23 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateNewExecution

func ValidateNewExecution(_ context.Context, execution Execution) error

Types

type ErrExecutionAlreadyExists

type ErrExecutionAlreadyExists struct {
	ExecutionID string
}

ErrExecutionAlreadyExists is returned when an execution already exists

func NewErrExecutionAlreadyExists

func NewErrExecutionAlreadyExists(id string) ErrExecutionAlreadyExists

func (ErrExecutionAlreadyExists) Error

type ErrExecutionAlreadyTerminal

type ErrExecutionAlreadyTerminal struct {
	ExecutionID string
	Actual      ExecutionState
	NewState    ExecutionState
}

ErrExecutionAlreadyTerminal is returned when an execution is already in terminal state and cannot be updated.

func NewErrExecutionAlreadyTerminal

func NewErrExecutionAlreadyTerminal(id string, actual ExecutionState, newState ExecutionState) ErrExecutionAlreadyTerminal

func (ErrExecutionAlreadyTerminal) Error

type ErrExecutionHistoryNotFound

type ErrExecutionHistoryNotFound struct {
	ExecutionID string
}

ErrExecutionHistoryNotFound is returned when the execution is not found

func NewErrExecutionHistoryNotFound

func NewErrExecutionHistoryNotFound(id string) ErrExecutionHistoryNotFound

func (ErrExecutionHistoryNotFound) Error

type ErrExecutionNotFound

type ErrExecutionNotFound struct {
	ExecutionID string
}

ErrExecutionNotFound is returned when the execution is not found

func NewErrExecutionNotFound

func NewErrExecutionNotFound(id string) ErrExecutionNotFound

func (ErrExecutionNotFound) Error

func (e ErrExecutionNotFound) Error() string

type ErrExecutionsNotFoundForShard

type ErrExecutionsNotFoundForShard struct {
	ShardID string
}

ErrExecutionNotFound is returned when the execution is not found

func NewErrExecutionsNotFound

func NewErrExecutionsNotFound(id string) ErrExecutionsNotFoundForShard

func (ErrExecutionsNotFoundForShard) Error

type ErrInvalidExecutionState

type ErrInvalidExecutionState struct {
	ExecutionID string
	Actual      ExecutionState
	Expected    ExecutionState
}

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

func NewErrInvalidExecutionState

func NewErrInvalidExecutionState(id string, actual ExecutionState, expected ExecutionState) ErrInvalidExecutionState

func (ErrInvalidExecutionState) Error

func (e ErrInvalidExecutionState) Error() string

type ErrInvalidExecutionVersion

type ErrInvalidExecutionVersion struct {
	ExecutionID string
	Actual      int
	Expected    int
}

ErrInvalidExecutionVersion is returned when an execution has an invalid version.

func NewErrInvalidExecutionVersion

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

func (ErrInvalidExecutionVersion) Error

type ErrNilExecution

type ErrNilExecution struct{}

ErrNilExecution is returned when the execution is nil

func NewErrNilExecution

func NewErrNilExecution() ErrNilExecution

func (ErrNilExecution) Error

func (e ErrNilExecution) Error() string

type Execution

type Execution struct {
	ID              string
	Shard           model.JobShard
	RequesterNodeID string
	ResourceUsage   model.ResourceUsageData
	State           ExecutionState
	Version         int
	CreateTime      time.Time
	UpdateTime      time.Time
	LatestComment   string
}

func GetActiveExecution

func GetActiveExecution(ctx context.Context, s ExecutionStore, shardID string) (Execution, error)

GetActiveExecution returns the active execution for a given shard. In case of a bug where we have more than a single active execution, the latest one is returned

func NewExecution

func NewExecution(
	id string,
	shard model.JobShard,
	requesterNodeID string,
	resourceUsage model.ResourceUsageData) *Execution

func (Execution) String

func (e Execution) String() string

string returns a string representation of the execution

type ExecutionHistory

type ExecutionHistory struct {
	ExecutionID   string
	PreviousState ExecutionState
	NewState      ExecutionState
	NewVersion    int
	Comment       string
	Time          time.Time
}

type ExecutionState

type ExecutionState int
const (
	ExecutionStateUndefined ExecutionState = iota
	ExecutionStateCreated
	ExecutionStateBidAccepted
	ExecutionStateRunning
	ExecutionStateWaitingVerification
	ExecutionStateResultAccepted
	ExecutionStatePublishing
	ExecutionStateCompleted
	ExecutionStateFailed
	ExecutionStateCancelled
)

func (ExecutionState) IsActive

func (s ExecutionState) IsActive() bool

IsActive returns true if the execution is active

func (ExecutionState) IsExecuting

func (s ExecutionState) IsExecuting() bool

IsExecuting returns true if the execution is running in the backend

func (ExecutionState) IsTerminal

func (s ExecutionState) IsTerminal() bool

IsTerminal returns true if the execution is terminal

func (ExecutionState) String

func (i ExecutionState) String() string

type ExecutionStore

type ExecutionStore interface {
	// GetExecution returns the execution for a given id
	GetExecution(ctx context.Context, id string) (Execution, error)
	// GetExecutions returns all the executions for a given shard
	GetExecutions(ctx context.Context, sharedID string) ([]Execution, error)
	// GetExecutionHistory returns the history of an execution
	GetExecutionHistory(ctx context.Context, id string) ([]ExecutionHistory, error)
	// CreateExecution creates a new execution for a given shard
	CreateExecution(ctx context.Context, execution Execution) error
	// UpdateExecutionState updates the execution state
	UpdateExecutionState(ctx context.Context, request UpdateExecutionStateRequest) error
	// DeleteExecution deletes an execution
	DeleteExecution(ctx context.Context, id string) error
}

ExecutionStore A metadata store of job executions handled by the current compute node

type ExecutionSummary

type ExecutionSummary struct {
	ExecutionID   string                  `json:"ExecutionID"`
	ShardID       string                  `json:"ShardID"`
	State         string                  `json:"State"`
	ResourceUsage model.ResourceUsageData `json:"ResourceUsage"`
}

Summary of an execution that is used in logging and debugging.

func NewExecutionSummary

func NewExecutionSummary(execution Execution) ExecutionSummary

NewExecutionSummary generate a summary from an execution

type UpdateExecutionStateRequest

type UpdateExecutionStateRequest struct {
	ExecutionID     string
	NewState        ExecutionState
	ExpectedState   ExecutionState
	ExpectedVersion int
	Comment         string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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