data

package
v0.0.0-...-24bddef Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *sql.DB
View Source
var ErrNotFound = errors.New("data: not found")
View Source
var JobQueueNotification *sync.Cond = sync.NewCond(&sync.Mutex{})

Functions

func BuildURLForArtifact

func BuildURLForArtifact(a *Artifact) (string, error)

func EnqueueJob

func EnqueueJob(name string, parameters map[string]string, priority int, userID int) (int64, error)

func GetResultForJob

func GetResultForJob(job *Job) (string, error)

func Init

func Init() error

func InsertResult

func InsertResult(tx *sql.Tx, job *Job, data string) error

func MarkJobCompleted

func MarkJobCompleted(tx *sql.Tx, job *Job) error

func MarkJobFailed

func MarkJobFailed(tx *sql.Tx, job *Job) error

func MarkJobStarted

func MarkJobStarted(job *Job) error

func UploadArtifact

func UploadArtifact(name string, f fs.File, job *Job) error

Types

type Artifact

type Artifact struct {
	ID      int    `json:"id"`
	Name    string `json:"name"`
	MIME    string `json:"mime"`
	Size    int64  `json:"size"`
	UUID    string `json:"uuid"`
	Created int64  `json:"created"`
	JobID   int    `json:"jobID"`
}

func GetArtifactByID

func GetArtifactByID(id int) (Artifact, error)

func GetArtifactsForJob

func GetArtifactsForJob(job *Job) ([]Artifact, error)

type Job

type Job struct {
	ID          int               `json:"id"`
	Status      JobStatus         `json:"-"`
	StatusText_ string            `json:"status"`
	Priority    int               `json:"priority"`
	Name        string            `json:"name"`
	Parameters  map[string]string `json:"parameters"`
	Created     int               `json:"created"`
	Started     *int              `json:"started"`
	Completed   *int              `json:"completed"`
	UserID      int               `json:"userID"`
}

func GetJobByID

func GetJobByID(id int) (Job, error)

func GetNextJobInQueue

func GetNextJobInQueue() (*Job, error)

type JobSpec

type JobSpec struct {
	Command          string
	Arguments        []string
	WorkingDirectory string
	PreserveEnvVars  []string
	Timeout          duration

	Parameter []JobSpecParameter
}

func ParseJobSpec

func ParseJobSpec(filename string) (JobSpec, error)

type JobSpecParameter

type JobSpecParameter struct {
	Name string
	Type JobSpecParameterType
}

func (*JobSpecParameter) CheckValidType

func (p *JobSpecParameter) CheckValidType() error

func (*JobSpecParameter) ParseValue

func (p *JobSpecParameter) ParseValue(value string) (string, bool)

type JobSpecParameterType

type JobSpecParameterType string
const (
	JobSpecParameterTypeString JobSpecParameterType = "string"
	JobSpecParameterTypeInt    JobSpecParameterType = "int"
)

type JobStatus

type JobStatus int
const (
	JobStatusQueued    JobStatus = 0
	JobStatusStarted   JobStatus = 1
	JobStatusCompleted JobStatus = 2
	JobStatusFailed    JobStatus = 3
)

Jump to

Keyboard shortcuts

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