services

package
v0.0.0-...-dedba89 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogError

func LogError(err error, context ...map[string]interface{}) bool

LogError returns true on error

Types

type APIService

type APIService struct {
	HTTPServer    *http.Server
	HTTPTLSServer *http.Server
	// contains filtered or unexported fields
}

APIService the service handling the API

func NewAPIService

func NewAPIService(config *models.Config, getRouter func() *mux.Router) *APIService

NewAPIService create new API service

func (*APIService) Start

func (service *APIService) Start()

Start the API service

type CleanupService

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

CleanupService cleanupservice cleansup stuff in background from DB

func NewClienupService

func NewClienupService(config *models.Config, db *gorm.DB) *CleanupService

NewClienupService create a new cleanupservice

func (*CleanupService) Start

func (cs *CleanupService) Start()

Start starts the service

type ContainerGetter

type ContainerGetter func(jobType libremotebuild.JobType) (string, error)

ContainerGetter get container for job

type ContainerService

type ContainerService struct {
	Config *models.Config
}

ContainerService provides management for container versions and availability

func NewContainerService

func NewContainerService(config *models.Config) *ContainerService

NewContainerService create a new container Service

func (*ContainerService) GetContainer

func (cs *ContainerService) GetContainer(job libremotebuild.JobType) (string, error)

GetContainer for a job

type JobQueue

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

JobQueue a queue for jobs

func NewJobQueue

func NewJobQueue(db *gorm.DB, config *models.Config, getContainer ContainerGetter) *JobQueue

NewJobQueue create a new JobQueue

func (*JobQueue) AddJob

func (jq *JobQueue) AddJob(job *models.Job) (*JobQueueItem, error)

AddJob to a jobqueue

func (*JobQueue) AddNewJob

func (jq *JobQueue) AddNewJob(db *gorm.DB, Type libremotebuild.JobType, uploadType libremotebuild.UploadType, args map[string]string, useCcache bool) (*JobQueueItem, error)

AddNewJob create job and add to queue

func (*JobQueue) FindJob

func (jq *JobQueue) FindJob(jobID uint) *JobQueueItem

FindJob find job in queue

func (*JobQueue) GetJobQueuePos

func (jq *JobQueue) GetJobQueuePos(jiq *JobQueueItem) int

GetJobQueuePos position of job in the queue

func (*JobQueue) GetJobs

func (jq *JobQueue) GetJobs() []JobQueueItem

GetJobs return jobs in queue

func (*JobQueue) Load

func (jq *JobQueue) Load() error

Load queue from Db

func (*JobQueue) RemoveJob

func (jq *JobQueue) RemoveJob(jobID uint)

RemoveJob remove item from jobQueue

func (*JobQueue) Run

func (jq *JobQueue) Run()

Run the queue

func (*JobQueue) Start

func (jq *JobQueue) Start()

Start the queue async

type JobQueueItem

type JobQueueItem struct {
	gorm.Model

	JobID uint        `sql:"index"`
	Job   *models.Job `gorm:"association_autoupdate:false;association_autocreate:false"`

	Position uint // The position in the Queue

	RunningSince time.Time `gorm:"-"`
	Deleted      bool      `gorm:"-"`
}

JobQueueItem Item in JobQueue

func (*JobQueueItem) Load

func (jqi *JobQueueItem) Load(db *gorm.DB, config *models.Config) error

Load JobQueueItem

func (JobQueueItem) TableName

func (jqi JobQueueItem) TableName() string

TableName use "JobQueue" as tablename

type JobService

type JobService struct {
	*gorm.DB

	Queue *JobQueue
	// contains filtered or unexported fields
}

JobService managing jobs

func NewJobService

func NewJobService(config *models.Config, db *gorm.DB, getContainer ContainerGetter) *JobService

NewJobService create a new jobservice

func (*JobService) GetOldJobs

func (js *JobService) GetOldJobs(limit int) ([]models.Job, error)

GetOldJobs return n(limit) old jobs

func (*JobService) GetOldLogs

func (js *JobService) GetOldLogs(jobID uint) (string, error)

GetOldLogs get old logs for job

func (*JobService) Run

func (js *JobService) Run()

Run Start a job and await complete

func (*JobService) Start

func (js *JobService) Start()

Start the jobservice

func (*JobService) Stop

func (js *JobService) Stop()

Stop the jobservice

type SortByPosition

type SortByPosition []JobQueueItem

SortByPosition sort by JobQueueItem position

func (SortByPosition) Len

func (a SortByPosition) Len() int

func (SortByPosition) Less

func (a SortByPosition) Less(i, j int) bool

func (SortByPosition) Swap

func (a SortByPosition) Swap(i, j int)

Jump to

Keyboard shortcuts

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