taskrunner

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JOB_NAME map[JobType]string = map[JobType]string{
	JobNone:            "Unknown job",
	JobCreateMachine:   "Creating machine",
	JobDeleteMachine:   "Deleting machine",
	JobStartMachine:    "Starting machine",
	JobStopMachine:     "Stopping machine",
	JobTransferMachine: "Transferring machine",
	JobResizeMachine:   "Resizing machine",
}
View Source
var TASK_NAME map[TaskType]string = map[TaskType]string{
	TaskNone:                "Unknown task",
	TaskComplete:            "Task complete",
	TaskCreateRole:          "Creating role",
	TaskCreateSecurityGroup: "Creating security group",
	TaskCreateInstance:      "Creating instance",
	TaskCreateNewVolume:     "Creating new volume",
	TaskDeleteImage:         "Deleting image",
	TaskDeleteSnapshot:      "Deleting snapshot",
	TaskResizeVolume:        "Resizing volume",
	TaskTransferImage:       "Transferring image",
	TaskTransferSnapshot:    "Transferring snapshot",
	TaskRequestSpotInstance: "Requesting spot instance",
	TaskSaveInstance:        "Saving instance",
	TaskStartInstance:       "Starting instance",
	TaskStopInstance:        "Stopping instance",
}

Functions

This section is empty.

Types

type Job

type Job struct {
	Id        int64
	MachineId int64
	Metadata  string
	Type      JobType
	Status    Status
	Complete  bool
	Created   time.Time `xorm:"created"`
	Updated   time.Time `xorm:"updated"`
}

func NewJob

func NewJob(jobType JobType, data JobData) Job

func (*Job) GetTasks

func (j *Job) GetTasks() []Task

type JobData

type JobData struct {
	MachineId int64
	Metadata  string
}

type JobType

type JobType = int64
const (
	JobNone JobType = iota
	JobCreateMachine
	JobDeleteMachine
	JobStartMachine
	JobStopMachine
	JobTransferMachine
	JobResizeMachine
)
const (
	TaskNone JobType = iota
	TaskComplete
	TaskCreateRole
	TaskCreateSecurityGroup
	TaskCreateInstance
	TaskCreateNewVolume
	TaskDeleteImage
	TaskDeleteSnapshot
	TaskRequestSpotInstance
	TaskResizeVolume
	TaskTransferImage
	TaskTransferSnapshot
	TaskSaveInstance
	TaskStartInstance
	TaskStopInstance
)

type Status

type Status int64
const (
	PENDING Status = iota
	COMPLETE
	ERROR
	CANCELED
)

type Task

type Task struct {
	Id        int64
	JobId     int64
	Type      TaskType
	ErrorInfo string `xorm:"error_info"`
	Status    Status
	Metadata  string
	Created   time.Time `xorm:"created"`
	Updated   time.Time `xorm:"updated"`
}

func NewTask

func NewTask(jobId int64, taskType JobType) Task

func (*Task) HandleTask

func (t *Task) HandleTask(client awsclient.AWSClient, machine models.Machine)

type TaskLog

type TaskLog struct {
	Id        int64  `json:"id"`
	Event     string `json:"event"`
	ErrorInfo string `json:"errorInfo"`
	Timestamp int64  `json:"timestamp"`
	Status    Status `json:"status"`
}

func GetTaskLog

func GetTaskLog() []TaskLog

type TaskRunner

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

func NewTaskRunner

func NewTaskRunner() TaskRunner

func (*TaskRunner) GetCurrentJob

func (t *TaskRunner) GetCurrentJob() int64

func (*TaskRunner) IsRunning

func (t *TaskRunner) IsRunning() bool

func (*TaskRunner) Queue

func (t *TaskRunner) Queue(jobType JobType, jobData JobData) (int64, error)

func (*TaskRunner) Start

func (t *TaskRunner) Start(client awsclient.AWSClient)

func (*TaskRunner) Stop

func (t *TaskRunner) Stop()

type TaskSaveInstanceMetadata

type TaskSaveInstanceMetadata struct {
	InstanceId    string
	VolumeId      string
	NewAmiId      string
	NewSnapshotId string
}

type TaskType

type TaskType = int64

Jump to

Keyboard shortcuts

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