state

package
v0.101.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// EngineStateInProgress pipeline in execution progress
	EngineStateInProgress string = "in-progress"
	// EngineStateFinished pipeline is finished execution
	EngineStateFinished string = "finished"

	// EngineStatusSuccess marks the engine as finished successfully
	EngineStatusSuccess = "Success"

	// EngineStatusFailed marks the engine as finished with error
	EngineStatusFailed = "failed"

	// TaskStateElected task is in progress
	TaskStateElected string = "elected"

	// TaskStateInProgress task is in progress
	TaskStateInProgress string = EngineStateInProgress

	// TaskStateFinished task is finished
	TaskStateFinished string = EngineStateFinished

	// TaskStatusSuccess set on the task status in case task was finished successfully
	TaskStatusSuccess = "Success"

	// TaskStatusFailed set on the task status in case task was finished with error
	TaskStatusFailed = "failed"
)
View Source
const (
	// EventEngineStarted fired when the engine started
	EventEngineStarted = "engine.started"
	// EventEngineFinished fired when the engine is finished
	EventEngineFinished = "engine.finished"
	// EventTaskStarted fired when task is started
	EventTaskStarted = "task.started"
	// EventTaskFinished fired when task is finished
	EventTaskFinished = "task.finished"
	// EventTaskElected fired when task is elected
	EventTaskElected = "task.elected"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddRealtedTaskToEventReuqest

type AddRealtedTaskToEventReuqest struct {
	EventID string
	Task    []string
}

AddRealtedTaskToEventReuqest request to add related task to the event

type ElectTasksRequest

type ElectTasksRequest struct {
	Tasks []task.Task
}

ElectTasksRequest request to mark tasks as elected

type Options

type Options struct {
	Name string
	// EventChan to write new event to the channel once a chance was applied
	EventChan chan *event.Event
	// CommandsChan to receive commands to create new change channel
	CommandsChan chan string
	// StateUpdateRequest to receive updated on the state in realtime
	StateUpdateRequest chan UpdateRequest
	Logger             logger.Logger
	WG                 *sync.WaitGroup
}

Options to pass to the state

type ServiceState

type ServiceState struct {
}

ServiceState is a representation of a state of one service

type State

type State interface {
	Copy() (State, error)
	Tasks() map[string]TaskState
	Events() []event.Event
	Services() []ServiceState
	StateBytes() ([]byte, error)
	EventBytes() ([]byte, error)
	StartProcess()
	GetStepOutputInto(step string, target interface{}) error
}

State holds all the data of the pipeline execution flow

func New

func New(opt *Options) State

New builds nnew State from options

type TaskState

type TaskState struct {
	State  string    `yaml:"state"`
	Status string    `yaml:"status"`
	Task   task.Task `yaml:"task"`
	Times  TaskTimes `yaml:"times"`
	Output string    `yaml:"output"`
	Error  error     `yaml:"error"`
	Logger string    `yaml:"logger"`
}

TaskState is a representation of a state of one task

type TaskTimes

type TaskTimes struct {
	Started  time.Time `yaml:"started"`
	Finished time.Time `yaml:"finished"`
}

TaskTimes hold start and finish time of task

type UpdateRequest

type UpdateRequest struct {
	Metadata                     UpdateRequestMetadata
	ElectTasksRequest            *ElectTasksRequest
	AddRealtedTaskToEventReuqest *AddRealtedTaskToEventReuqest
	UpdateTaskStateRequest       *UpdateTaskStateRequest
	UpdateStateMetadataRequest   *UpdateStateMetadataRequest
}

UpdateRequest request update the state

type UpdateRequestMetadata

type UpdateRequestMetadata struct {
	CreatedAt time.Time
}

UpdateRequestMetadata metadata to UpdateRequest

type UpdateStateMetadataRequest

type UpdateStateMetadataRequest struct {
	State  string
	Status string
}

UpdateStateMetadataRequest request to update task state metadata

type UpdateTaskStateRequest

type UpdateTaskStateRequest struct {
	State TaskState
}

UpdateTaskStateRequest request to update task state

Jump to

Keyboard shortcuts

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