db

package
v0.0.0-...-5d714f6 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package db defines data transfer obejects

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeginTransactions

func BeginTransactions() *gorm.DB

BeginTransactions starts a transaction

func Commit

func Commit(tx *gorm.DB)

Commit コミットします

func Enqueue

func Enqueue(message string) error

Enqueue set a job in the queue

func GetCache

func GetCache(key string) ([]byte, error)

GetCache returns []bytes

func ImageError

func ImageError(owner, caption string, imageAction ImageAction, tag string, err error)

ImageError persists an image error

func Initialize

func Initialize()

Initialize inits its db settings

func JobError

func JobError(owner, caption string, jobAction JobAction, id string, err error)

JobError persists a job error

func OnlineError

func OnlineError(owner, caption string, onlineAction OnlineAction, err error)

OnlineError persists an online error

func Ping

func Ping() error

Ping verifies a connection to the database is still alive, establishing a connection if necessary.

func RemoveBuildingImage

func RemoveBuildingImage(name string) error

RemoveBuildingImage removes from BUILDING cache

func RemoveBuildingJobImagesJobs

func RemoveBuildingJobImagesJobs(id string) error

RemoveBuildingJobImagesJobs removes job

func RemoveJob

func RemoveJob(id string) error

RemoveJob removes a job you specified

func RemovePullingImage

func RemovePullingImage(name string) error

RemovePullingImage removes from PULLING cache

func RemovePushingJobImageJobs

func RemovePushingJobImageJobs(id string) error

RemovePushingJobImageJobs removes job

func Rollback

func Rollback(tx *gorm.DB)

Rollback ロールバックします

func SetCache

func SetCache(key string, value []byte, duration *time.Duration) error

SetCache with the specified function

func SetupQueue

func SetupQueue(handler interface{}, fallbackHandler interface{})

SetupQueue start its service

func Shutdown

func Shutdown()

Shutdown close its connection

func ShutdownCache

func ShutdownCache()

ShutdownCache stop its service

func ShutdownQueue

func ShutdownQueue()

ShutdownQueue stop its service

func UpdateJob

func UpdateJob(id string, from, to JobAction, status JobStatus, targetID *string) error

UpdateJob update job status

Types

type Error

type Error struct {
	gorm.Model
	Owner        string  `gorm:"index:owner;"`
	Caption      string  `gorm:"column:caption;"`
	ErrorMessage *string `gorm:"column:error_detail;"`
	OnlineAction *string `gorm:"column:online_action;"`
	ImageAction  *string `gorm:"column:image_action;"`
	ImageTag     *string `gorm:"column:image_tag;"`
	JobAction    *string `gorm:"column:job_action;"`
	JobID        *string `gorm:"column:job_id;"`
}

Error represents error information

func FindErrors

func FindErrors(owner string) ([]*Error, error)

FindErrors search errors

type Image

type Image struct {
	gorm.Model
	Tag    string `gorm:"index:tag;"`
	Action string `gorm:"index:action;"`
	Owner  string
}

Image represents cached image information

func FindImages

func FindImages(action ImageAction) ([]*Image, error)

FindImages search images based on the ImageType

func (*Image) Create

func (image *Image) Create() error

Create persists its data to database

type ImageAction

type ImageAction string

ImageAction defines how handle a image

const (
	ImageActionPulling  ImageAction = "pulling"
	ImageActionBuilding ImageAction = "building"
)

ImageActions

type Job

type Job struct {
	gorm.Model
	JobID       string `gorm:"column:job_id;index:jobid;"`
	Action      string `gorm:"index:action;"`
	Platform    int
	Status      string
	DockerImage string `gorm:"column:docker_image;"`
	PythonFile  string `gorm:"column:python_file;"`
	Workspaces  string
	Commands    string
	CPU         int64
	Memory      int64
	GPU         int64
	CoreType    string `gorm:"column:core_type;"`
	Cores       int64
	TargetID    string `gorm:"column:target_id;"` // Job ID of the target platform
}

Job represents cached job information

func GetJob

func GetJob(jobID string) (*Job, error)

GetJob returns job specified

func GetJobs

func GetJobs() ([]*Job, error)

GetJobs returns jobs under BUILDING job images / Rescale status

func (*Job) Create

func (job *Job) Create() error

Create persists its data to database

type JobAction

type JobAction string

JobAction defines how to handle the job

const (
	JobActionBuilding   JobAction = "building"
	JobActionPushing    JobAction = "pushing"
	JobActionKubernetes JobAction = "kubernetes"
	JobActionRescale    JobAction = "rescale"
)

JobActions

type JobStatus

type JobStatus string

JobStatus defines the status of a job

const (
	JobStatusImageBuilding  JobStatus = "building"
	JobStatusImagePushing   JobStatus = "pushing"
	JobStatusK8sInit        JobStatus = "k8s-job-init" // Kubernetes
	JobStatusK8sStarted     JobStatus = "k8s-job-started"
	JobStatusK8sPending     JobStatus = "k8s-job-pending"
	JobStatusK8sRunning     JobStatus = "k8s-job-runnning"
	JobStatusK8sSucceeded   JobStatus = "k8s-job-succeeded"
	JobStatusK8sFailed      JobStatus = "k8s-job-failed"
	JobStatusRescaleSend    JobStatus = "rescale-send" // Rescale
	JobStatusRescaleStarted JobStatus = "rescale-start"
	JobStatusRescaleRunning JobStatus = "rescale-runnning"
	JobStatusRescaleSucceed JobStatus = "rescale-succeeded"
	JobStatusRescaleFailed  JobStatus = "rescale-failed"
	JobStatusUnknown        JobStatus = "unknown"
)

JobStatuses

func (JobStatus) Value

func (s JobStatus) Value() *string

Value casts its value to the pointer

type OnlineAction

type OnlineAction string

OnlineAction defines the actions on the core business logic

const (
	OnlineActionWrapJupyter  OnlineAction = "wrap-jupyternotebook"
	OnlineActionRunJupyter   OnlineAction = "run-jupyternotebook"
	OnlineActionSelectData   OnlineAction = "select-data"
	OnlineActionDeleteImages OnlineAction = "delete-images"
	OnlineActionUpdateStatus OnlineAction = "update-dbstatus"
	OnlineActionConvertToSig OnlineAction = "convert-singularity"
)

OnlineAction

type PlatformType

type PlatformType int

PlatformType defines in where the job will be run

const (
	PlatformKubernetes PlatformType = iota
	PlatformRescale
)

PlatformTypes

func (PlatformType) String

func (p PlatformType) String() string

Jump to

Keyboard shortcuts

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