state

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetJobIdsByInstance

func GetJobIdsByInstance(config config.Config, bucketName string) (map[int64][]int64, error)

func MergeStates

func MergeStates(existingState, newState *State)

func UpdateState

func UpdateState(config config.Config, bucketName string, newState *State) error

Types

type JobInfo

type JobInfo struct {
	ID          int64     `json:"id"`
	StartedAt   int64     `json:"started_at"` // Unix timestamp
	CompletedAt int64     `json:"completed_at"`
	UpdatedAt   int64     `json:"updated_at"`
	Status      JobStatus `json:"status"`
	Delete      bool
	Droplet     do.Droplet `json:"droplet"`
}

func GetLatestCompletedJob

func GetLatestCompletedJob(bucketName string, state *State) (*JobInfo, error)

type JobStatus

type JobStatus string
const (
	Provisioning JobStatus = "provisioning"
	Running      JobStatus = "running"
	Completed    JobStatus = "completed"
	Failed       JobStatus = "failed"
	Cancelled    JobStatus = "cancelled"
	Timedout     JobStatus = "timedout"
)

type State

type State struct {
	Jobs []JobInfo `json:"jobs"`
}

func GetState

func GetState(config config.Config, bucketName string) (*State, error)

func (*State) CancelRunningJobs

func (s *State) CancelRunningJobs(config config.Config, bucketName string) error

func (*State) CreateJob

func (s *State) CreateJob(job JobInfo)

CreateJob adds a new job to the state.

func (*State) DeleteJob

func (s *State) DeleteJob(jobID int64)

DeleteJob removes a job with the specified ID from the state.

func (*State) GetJob

func (s *State) GetJob(jobID int64) *JobInfo

GetJob returns a job with the specified ID or nil if not found.

func (*State) GetLatestJob

func (s *State) GetLatestJob() *JobInfo

GetLatestJob returns the latest job in the state.

Jump to

Keyboard shortcuts

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