persistence

package
v0.0.0-...-8b9a2a1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

Package persistence provides the database interface for Flamenco Manager.

SPDX-License-Identifier: GPL-3.0-or-later

SPDX-License-Identifier: GPL-3.0-or-later

SPDX-License-Identifier: GPL-3.0-or-later

Package persistence provides the database interface for Flamenco Manager.

Index

Constants

View Source
const TestDSN = "file::memory:"

Change this to a filename if you want to run a single test and inspect the resulting database.

Variables

View Source
var (
	ErrJobNotFound       = PersistenceError{Message: "job not found", Err: gorm.ErrRecordNotFound}
	ErrTaskNotFound      = PersistenceError{Message: "task not found", Err: gorm.ErrRecordNotFound}
	ErrWorkerNotFound    = PersistenceError{Message: "worker not found", Err: gorm.ErrRecordNotFound}
	ErrWorkerTagNotFound = PersistenceError{Message: "worker tag not found", Err: gorm.ErrRecordNotFound}

	ErrDeletingWithoutFK = errors.New("refusing to delete a job when foreign keys are not enabled on the database")
)
View Source
var ErrIntegrity = errors.New("database integrity check failed")

Functions

func ErrIsDBBusy

func ErrIsDBBusy(err error) bool

ErrIsDBBusy returns true when the error is a "database busy" error.

func NewDBLogger

func NewDBLogger(zlog zerolog.Logger) *dbLogger

NewDBLogger wraps a zerolog logger to implement a Gorm logger interface.

Types

type Command

type Command struct {
	Name       string             `json:"name"`
	Parameters StringInterfaceMap `json:"parameters"`
}

type Commands

type Commands []Command

func (*Commands) Scan

func (c *Commands) Scan(value interface{}) error

func (Commands) Value

func (c Commands) Value() (driver.Value, error)

type DB

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

DB provides the database interface.

func CreateTestDB

func CreateTestDB(t *testing.T) (db *DB, closer func())

func OpenDB

func OpenDB(ctx context.Context, dsn string) (*DB, error)

func (*DB) AddWorkerToJobBlocklist

func (db *DB) AddWorkerToJobBlocklist(ctx context.Context, job *Job, worker *Worker, taskType string) error

AddWorkerToJobBlocklist prevents this Worker of getting any task, of this type, on this job, from the task scheduler.

func (*DB) AddWorkerToTaskFailedList

func (db *DB) AddWorkerToTaskFailedList(ctx context.Context, t *Task, w *Worker) (numFailed int, err error)

AddWorkerToTaskFailedList records that the given worker failed the given task. This information is not used directly by the task scheduler. It's used to determine whether there are any workers left to perform this task, and thus whether it should be hard- or soft-failed.

Calling this multiple times with the same task/worker is a no-op.

Returns the new number of workers that failed this task.

func (*DB) ClearFailureListOfJob

func (db *DB) ClearFailureListOfJob(ctx context.Context, j *Job) error

ClearFailureListOfJob en-mass, for all tasks of this job, clears the list of workers that failed those tasks.

func (*DB) ClearFailureListOfTask

func (db *DB) ClearFailureListOfTask(ctx context.Context, t *Task) error

ClearFailureListOfTask clears the list of workers that failed this task.

func (*DB) ClearJobBlocklist

func (db *DB) ClearJobBlocklist(ctx context.Context, job *Job) error

ClearJobBlocklist removes the entire blocklist of this job.

func (*DB) Close

func (db *DB) Close() error

Close closes the connection to the database.

func (*DB) CountTaskFailuresOfWorker

func (db *DB) CountTaskFailuresOfWorker(ctx context.Context, job *Job, worker *Worker, taskType string) (int, error)

CountTaskFailuresOfWorker returns the number of task failures of this worker, on this particular job and task type.

func (*DB) CountTasksOfJobInStatus

func (db *DB) CountTasksOfJobInStatus(
	ctx context.Context,
	job *Job,
	taskStatuses ...api.TaskStatus,
) (numInStatus, numTotal int, err error)

func (*DB) CreateWorker

func (db *DB) CreateWorker(ctx context.Context, w *Worker) error

func (*DB) CreateWorkerTag

func (db *DB) CreateWorkerTag(ctx context.Context, wc *WorkerTag) error

func (*DB) DeleteJob

func (db *DB) DeleteJob(ctx context.Context, jobUUID string) error

DeleteJob deletes a job from the database. The deletion cascades to its tasks and other job-related tables.

func (*DB) DeleteWorker

func (db *DB) DeleteWorker(ctx context.Context, uuid string) error

func (*DB) DeleteWorkerTag

func (db *DB) DeleteWorkerTag(ctx context.Context, uuid string) error

DeleteWorkerTag deletes the given tag, after unassigning all workers from it.

func (*DB) FetchJob

func (db *DB) FetchJob(ctx context.Context, jobUUID string) (*Job, error)

FetchJob fetches a single job, without fetching its tasks.

func (*DB) FetchJobBlocklist

func (db *DB) FetchJobBlocklist(ctx context.Context, jobUUID string) ([]JobBlock, error)

func (*DB) FetchJobsDeletionRequested

func (db *DB) FetchJobsDeletionRequested(ctx context.Context) ([]string, error)

func (*DB) FetchJobsInStatus

func (db *DB) FetchJobsInStatus(ctx context.Context, jobStatuses ...api.JobStatus) ([]*Job, error)

func (*DB) FetchSleepScheduleWorker

func (db *DB) FetchSleepScheduleWorker(ctx context.Context, schedule *SleepSchedule) error

FetchSleepScheduleWorker sets the given schedule's `Worker` pointer.

func (*DB) FetchSleepSchedulesToCheck

func (db *DB) FetchSleepSchedulesToCheck(ctx context.Context) ([]*SleepSchedule, error)

FetchSleepSchedulesToCheck returns the sleep schedules that are due for a check.

func (*DB) FetchTask

func (db *DB) FetchTask(ctx context.Context, taskUUID string) (*Task, error)

func (*DB) FetchTaskFailureList

func (db *DB) FetchTaskFailureList(ctx context.Context, t *Task) ([]*Worker, error)

func (*DB) FetchTasksOfJob

func (db *DB) FetchTasksOfJob(ctx context.Context, job *Job) ([]*Task, error)

FetchTaskIDsOfJob returns all tasks of the given job.

func (*DB) FetchTasksOfJobInStatus

func (db *DB) FetchTasksOfJobInStatus(ctx context.Context, job *Job, taskStatuses ...api.TaskStatus) ([]*Task, error)

FetchTasksOfJobInStatus returns those tasks of the given job that have any of the given statuses.

func (*DB) FetchTasksOfWorkerInStatus

func (db *DB) FetchTasksOfWorkerInStatus(ctx context.Context, worker *Worker, taskStatus api.TaskStatus) ([]*Task, error)

func (*DB) FetchTasksOfWorkerInStatusOfJob

func (db *DB) FetchTasksOfWorkerInStatusOfJob(ctx context.Context, worker *Worker, taskStatus api.TaskStatus, job *Job) ([]*Task, error)

func (*DB) FetchTimedOutTasks

func (db *DB) FetchTimedOutTasks(ctx context.Context, untouchedSince time.Time) ([]*Task, error)

FetchTimedOutTasks returns a slice of tasks that have timed out.

In order to time out, a task must be in status `active` and not touched by a Worker since `untouchedSince`.

The returned tasks also have their `Job` and `Worker` fields set.

func (*DB) FetchTimedOutWorkers

func (db *DB) FetchTimedOutWorkers(ctx context.Context, lastSeenBefore time.Time) ([]*Worker, error)

func (*DB) FetchWorker

func (db *DB) FetchWorker(ctx context.Context, uuid string) (*Worker, error)

func (*DB) FetchWorkerSleepSchedule

func (db *DB) FetchWorkerSleepSchedule(ctx context.Context, workerUUID string) (*SleepSchedule, error)

FetchWorkerSleepSchedule fetches the worker's sleep schedule. It does not fetch the worker itself. If you need that, call `FetchSleepScheduleWorker()` afterwards.

func (*DB) FetchWorkerTag

func (db *DB) FetchWorkerTag(ctx context.Context, uuid string) (*WorkerTag, error)

func (*DB) FetchWorkerTags

func (db *DB) FetchWorkerTags(ctx context.Context) ([]*WorkerTag, error)

func (*DB) FetchWorkerTask

func (db *DB) FetchWorkerTask(ctx context.Context, worker *Worker) (*Task, error)

FetchWorkerTask returns the most recent task assigned to the given Worker.

func (*DB) FetchWorkers

func (db *DB) FetchWorkers(ctx context.Context) ([]*Worker, error)

func (*DB) GetLastRenderedJobUUID

func (db *DB) GetLastRenderedJobUUID(ctx context.Context) (string, error)

GetLastRendered returns the UUID of the job with the most recent rendered image.

func (*DB) HasWorkerTags

func (db *DB) HasWorkerTags(ctx context.Context) (bool, error)

HasWorkerTags returns whether there are any tags defined at all.

func (*DB) JobHasTasksInStatus

func (db *DB) JobHasTasksInStatus(ctx context.Context, job *Job, taskStatus api.TaskStatus) (bool, error)

func (*DB) PeriodicIntegrityCheck

func (db *DB) PeriodicIntegrityCheck(
	ctx context.Context,
	period time.Duration,
	onErrorCallback func(),
)

PeriodicIntegrityCheck periodically checks the database integrity. This function only returns when the context is done.

func (*DB) QueryJobTaskSummaries

func (db *DB) QueryJobTaskSummaries(ctx context.Context, jobUUID string) ([]*Task, error)

QueryJobTaskSummaries retrieves all tasks of the job, but not all fields of those tasks. Fields are synchronised with api.TaskSummary.

func (*DB) QueryJobs

func (db *DB) QueryJobs(ctx context.Context, apiQ api.JobsQuery) ([]*Job, error)

func (*DB) RemoveFromJobBlocklist

func (db *DB) RemoveFromJobBlocklist(ctx context.Context, jobUUID, workerUUID, taskType string) error

func (*DB) RequestIntegrityCheck

func (db *DB) RequestIntegrityCheck()

RequestIntegrityCheck triggers a check of the database persistency.

func (*DB) RequestJobDeletion

func (db *DB) RequestJobDeletion(ctx context.Context, j *Job) error

RequestJobDeletion sets the job's "DeletionRequestedAt" field to "now".

func (*DB) RequestJobMassDeletion

func (db *DB) RequestJobMassDeletion(ctx context.Context, lastUpdatedMax time.Time) ([]string, error)

RequestJobMassDeletion sets multiple job's "DeletionRequestedAt" field to "now". The list of affected job UUIDs is returned.

func (*DB) SaveJobPriority

func (db *DB) SaveJobPriority(ctx context.Context, j *Job) error

SaveJobPriority saves the job's Priority field.

func (*DB) SaveJobStatus

func (db *DB) SaveJobStatus(ctx context.Context, j *Job) error

SaveJobStatus saves the job's Status and Activity fields.

func (*DB) SaveJobStorageInfo

func (db *DB) SaveJobStorageInfo(ctx context.Context, j *Job) error

SaveJobStorageInfo saves the job's Storage field. NOTE: this function does NOT update the job's `UpdatedAt` field. This is necessary for `cmd/shaman-checkout-id-setter` to do its work quietly.

func (*DB) SaveTask

func (db *DB) SaveTask(ctx context.Context, t *Task) error

func (*DB) SaveTaskActivity

func (db *DB) SaveTaskActivity(ctx context.Context, t *Task) error

func (*DB) SaveTaskStatus

func (db *DB) SaveTaskStatus(ctx context.Context, t *Task) error

func (*DB) SaveWorker

func (db *DB) SaveWorker(ctx context.Context, w *Worker) error

func (*DB) SaveWorkerStatus

func (db *DB) SaveWorkerStatus(ctx context.Context, w *Worker) error

func (*DB) SaveWorkerTag

func (db *DB) SaveWorkerTag(ctx context.Context, tag *WorkerTag) error

func (*DB) ScheduleTask

func (db *DB) ScheduleTask(ctx context.Context, w *Worker) (*Task, error)

ScheduleTask finds a task to execute by the given worker. If no task is available, (nil, nil) is returned, as this is not an error situation. NOTE: this does not also fetch returnedTask.Worker, but returnedTask.WorkerID is set.

func (*DB) SetLastRendered

func (db *DB) SetLastRendered(ctx context.Context, j *Job) error

SetLastRendered sets this job as the one with the most recent rendered image.

func (*DB) SetWorkerSleepSchedule

func (db *DB) SetWorkerSleepSchedule(ctx context.Context, workerUUID string, schedule *SleepSchedule) error

func (*DB) SetWorkerSleepScheduleNextCheck

func (db *DB) SetWorkerSleepScheduleNextCheck(ctx context.Context, schedule *SleepSchedule) error

func (*DB) StoreAuthoredJob

func (db *DB) StoreAuthoredJob(ctx context.Context, authoredJob job_compilers.AuthoredJob) error

StoreJob stores an AuthoredJob and its tasks, and saves it to the database. The job will be in 'under construction' status. It is up to the caller to transition it to its desired initial status.

func (*DB) StoreAuthoredJobTaks

func (db *DB) StoreAuthoredJobTaks(
	ctx context.Context,
	job *Job,
	authoredJob *job_compilers.AuthoredJob,
) error

StoreAuthoredJobTaks is a low-level function that is only used for recreating an existing job's tasks. It stores `authoredJob`'s tasks, but attaches them to the already-persisted `job`.

func (*DB) TaskAssignToWorker

func (db *DB) TaskAssignToWorker(ctx context.Context, t *Task, w *Worker) error

func (*DB) TaskTouchedByWorker

func (db *DB) TaskTouchedByWorker(ctx context.Context, t *Task) error

TaskTouchedByWorker marks the task as 'touched' by a worker. This is used for timeout detection.

func (*DB) UpdateJobsTaskStatuses

func (db *DB) UpdateJobsTaskStatuses(ctx context.Context, job *Job,
	taskStatus api.TaskStatus, activity string) error

UpdateJobsTaskStatuses updates the status & activity of all tasks of `job`.

func (*DB) UpdateJobsTaskStatusesConditional

func (db *DB) UpdateJobsTaskStatusesConditional(ctx context.Context, job *Job,
	statusesToUpdate []api.TaskStatus, taskStatus api.TaskStatus, activity string) error

UpdateJobsTaskStatusesConditional updates the status & activity of the tasks of `job`, limited to those tasks with status in `statusesToUpdate`.

func (*DB) WorkerSeen

func (db *DB) WorkerSeen(ctx context.Context, w *Worker) error

WorkerSeen marks the worker as 'seen' by this Manager. This is used for timeout detection.

func (*DB) WorkerSetTags

func (db *DB) WorkerSetTags(ctx context.Context, worker *Worker, tagUUIDs []string) error

func (*DB) WorkersLeftToRun

func (db *DB) WorkersLeftToRun(ctx context.Context, job *Job, taskType string) (map[string]bool, error)

WorkersLeftToRun returns a set of worker UUIDs that can run tasks of the given type on the given job.

NOTE: this does NOT consider the task failure list, which blocks individual workers from individual tasks. This is ONLY concerning the job blocklist.

type GooseLogger

type GooseLogger struct{}

func (*GooseLogger) Fatalf

func (gl *GooseLogger) Fatalf(format string, v ...interface{})

func (*GooseLogger) Printf

func (gl *GooseLogger) Printf(format string, v ...interface{})

type Job

type Job struct {
	Model
	UUID string `gorm:"type:char(36);default:'';unique;index"`

	Name     string        `gorm:"type:varchar(64);default:''"`
	JobType  string        `gorm:"type:varchar(32);default:''"`
	Priority int           `gorm:"type:smallint;default:0"`
	Status   api.JobStatus `gorm:"type:varchar(32);default:''"`
	Activity string        `gorm:"type:varchar(255);default:''"`

	Settings StringInterfaceMap `gorm:"type:jsonb"`
	Metadata StringStringMap    `gorm:"type:jsonb"`

	DeleteRequestedAt sql.NullTime

	Storage JobStorageInfo `gorm:"embedded;embeddedPrefix:storage_"`

	WorkerTagID *uint
	WorkerTag   *WorkerTag `gorm:"foreignkey:WorkerTagID;references:ID;constraint:OnDelete:SET NULL"`
}

func (*Job) DeleteRequested

func (j *Job) DeleteRequested() bool

DeleteRequested returns whether deletion of this job was requested.

type JobBlock

type JobBlock struct {
	// Don't include the standard Gorm UpdatedAt or DeletedAt fields, as they're useless here.
	// Entries will never be updated, and should never be soft-deleted but just purged from existence.
	ID        uint
	CreatedAt time.Time

	JobID uint `gorm:"default:0;uniqueIndex:job_worker_tasktype"`
	Job   *Job `gorm:"foreignkey:JobID;references:ID;constraint:OnDelete:CASCADE"`

	WorkerID uint    `gorm:"default:0;uniqueIndex:job_worker_tasktype"`
	Worker   *Worker `gorm:"foreignkey:WorkerID;references:ID;constraint:OnDelete:CASCADE"`

	TaskType string `gorm:"uniqueIndex:job_worker_tasktype"`
}

JobBlock keeps track of which Worker is not allowed to run which task type on which job.

type JobStorageInfo

type JobStorageInfo struct {
	// ShamanCheckoutID is only set when the job was actually using Shaman storage.
	ShamanCheckoutID string `gorm:"type:varchar(255);default:''"`
}

JobStorageInfo contains info about where the job files are stored. It is intended to be used when removing a job, which may include the removal of its files.

type LastRendered

type LastRendered struct {
	Model
	JobID uint `gorm:"default:0"`
	Job   *Job `gorm:"foreignkey:JobID;references:ID;constraint:OnDelete:CASCADE"`
}

LastRendered only has one entry in its database table, to indicate the job that was the last to receive a "last rendered image" from a Worker. This is used to show the global last-rendered image in the web interface.

type Model

type Model struct {
	ID        uint `gorm:"primarykey"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

Model contains the common database fields for most model structs. It is a copy of the gorm.Model struct, but without the `DeletedAt` field. Soft deletion is not used by Flamenco. If it ever becomes necessary to support soft-deletion, see https://gorm.io/docs/delete.html#Soft-Delete

type PersistenceError

type PersistenceError struct {
	Message string // The error message.
	Err     error  // Any wrapped error.
}

func (PersistenceError) Error

func (e PersistenceError) Error() string

func (PersistenceError) Is

func (e PersistenceError) Is(err error) bool

type PragmaForeignKeyCheckResult

type PragmaForeignKeyCheckResult struct {
	Table  string `gorm:"column:table"`
	RowID  int    `gorm:"column:rowid"`
	Parent string `gorm:"column:parent"`
	FKID   int    `gorm:"column:fkid"`
}

type PragmaIntegrityCheckResult

type PragmaIntegrityCheckResult struct {
	Description string `gorm:"column:integrity_check"`
}

type SleepSchedule

type SleepSchedule struct {
	Model

	WorkerID uint    `gorm:"default:0;unique;index"`
	Worker   *Worker `gorm:"foreignkey:WorkerID;references:ID;constraint:OnDelete:CASCADE"`

	IsActive bool `gorm:"default:false;index"`

	// Space-separated two-letter strings indicating days of week the schedule is
	// active ("mo", "tu", etc.). Empty means "every day".
	DaysOfWeek string    `gorm:"default:''"`
	StartTime  TimeOfDay `gorm:"default:''"`
	EndTime    TimeOfDay `gorm:"default:''"`

	NextCheck time.Time
}

SleepSchedule belongs to a Worker, and determines when it's automatically sent to the 'asleep' and 'awake' states.

type StringInterfaceMap

type StringInterfaceMap map[string]interface{}

func (*StringInterfaceMap) Scan

func (js *StringInterfaceMap) Scan(value interface{}) error

func (StringInterfaceMap) Value

func (js StringInterfaceMap) Value() (driver.Value, error)

type StringStringMap

type StringStringMap map[string]string

func (*StringStringMap) Scan

func (js *StringStringMap) Scan(value interface{}) error

func (StringStringMap) Value

func (js StringStringMap) Value() (driver.Value, error)

type Task

type Task struct {
	Model
	UUID string `gorm:"type:char(36);default:'';unique;index"`

	Name     string         `gorm:"type:varchar(64);default:''"`
	Type     string         `gorm:"type:varchar(32);default:''"`
	JobID    uint           `gorm:"default:0"`
	Job      *Job           `gorm:"foreignkey:JobID;references:ID;constraint:OnDelete:CASCADE"`
	Priority int            `gorm:"type:smallint;default:50"`
	Status   api.TaskStatus `gorm:"type:varchar(16);default:''"`

	// Which worker is/was working on this.
	WorkerID      *uint
	Worker        *Worker   `gorm:"foreignkey:WorkerID;references:ID;constraint:OnDelete:SET NULL"`
	LastTouchedAt time.Time `gorm:"index"` // Should contain UTC timestamps.

	// Dependencies are tasks that need to be completed before this one can run.
	Dependencies []*Task `gorm:"many2many:task_dependencies;constraint:OnDelete:CASCADE"`

	Commands Commands `gorm:"type:jsonb"`
	Activity string   `gorm:"type:varchar(255);default:''"`
}

type TaskFailure

type TaskFailure struct {
	// Don't include the standard Gorm ID, UpdatedAt, or DeletedAt fields, as they're useless here.
	// Entries will never be updated, and should never be soft-deleted but just purged from existence.
	CreatedAt time.Time
	TaskID    uint    `gorm:"primaryKey;autoIncrement:false"`
	Task      *Task   `gorm:"foreignkey:TaskID;references:ID;constraint:OnDelete:CASCADE"`
	WorkerID  uint    `gorm:"primaryKey;autoIncrement:false"`
	Worker    *Worker `gorm:"foreignkey:WorkerID;references:ID;constraint:OnDelete:CASCADE"`
}

TaskFailure keeps track of which Worker failed which Task.

type TimeOfDay

type TimeOfDay struct {
	Hour   int
	Minute int
}

TimeOfDay represents a time of day, and can be converted to/from a string. Its date and timezone components are ignored, and the time is supposed to be interpreted as local time on any date (f.e. a scheduled sleep time of some Worker on a certain day-of-week & local timezone).

TimeOfDay structs can also represent "no value", which will be marshaled as an empty string.

func EmptyTimeOfDay

func EmptyTimeOfDay() TimeOfDay

EmptyTimeOfDay returns a TimeOfDay struct with no value. See `TimeOfDay.HasValue()`.

func MakeTimeOfDay

func MakeTimeOfDay(someTime time.Time) TimeOfDay

MakeTimeOfDay converts a time.Time into a TimeOfDay.

func (TimeOfDay) Equals

func (ot TimeOfDay) Equals(other TimeOfDay) bool

Equals returns True iff both times represent the same time of day.

func (TimeOfDay) HasValue

func (ot TimeOfDay) HasValue() bool

func (TimeOfDay) IsAfter

func (ot TimeOfDay) IsAfter(other TimeOfDay) bool

IsAfter returns True iff ot is after other. Ignores everything except hour and minute fields.

func (TimeOfDay) IsBefore

func (ot TimeOfDay) IsBefore(other TimeOfDay) bool

IsBefore returns True iff ot is before other. Ignores everything except hour and minute fields.

func (TimeOfDay) OnDate

func (ot TimeOfDay) OnDate(date time.Time) time.Time

OnDate returns the time of day in the local timezone on the given date.

func (*TimeOfDay) Scan

func (ot *TimeOfDay) Scan(value interface{}) error

Scan updates this TimeOfDay from the value stored in a database.

func (TimeOfDay) String

func (ot TimeOfDay) String() string

func (TimeOfDay) Value

func (ot TimeOfDay) Value() (driver.Value, error)

Value converts a TimeOfDay to a value usable by SQL databases.

type Worker

type Worker struct {
	Model
	DeletedAt gorm.DeletedAt `gorm:"index"`

	UUID   string `gorm:"type:char(36);default:'';unique;index"`
	Secret string `gorm:"type:varchar(255);default:''"`
	Name   string `gorm:"type:varchar(64);default:''"`

	Address    string           `gorm:"type:varchar(39);default:'';index"` // 39 = max length of IPv6 address.
	Platform   string           `gorm:"type:varchar(16);default:''"`
	Software   string           `gorm:"type:varchar(32);default:''"`
	Status     api.WorkerStatus `gorm:"type:varchar(16);default:''"`
	LastSeenAt time.Time        `gorm:"index"` // Should contain UTC timestamps.
	CanRestart bool             `gorm:"type:smallint;default:false"`

	StatusRequested   api.WorkerStatus `gorm:"type:varchar(16);default:''"`
	LazyStatusRequest bool             `gorm:"type:smallint;default:false"`

	SupportedTaskTypes string `gorm:"type:varchar(255);default:''"` // comma-separated list of task types.

	Tags []*WorkerTag `gorm:"many2many:worker_tag_membership;constraint:OnDelete:CASCADE"`
}

func (*Worker) Identifier

func (w *Worker) Identifier() string

func (*Worker) StatusChangeClear

func (w *Worker) StatusChangeClear()

StatusChangeClear clears the requested status change of the Worker. This just updates the Worker instance, but doesn't store the change in the database.

func (*Worker) StatusChangeRequest

func (w *Worker) StatusChangeRequest(status api.WorkerStatus, isLazyRequest bool)

StatusChangeRequest stores a requested status change on the Worker. This just updates the Worker instance, but doesn't store the change in the database.

func (*Worker) TaskTypes

func (w *Worker) TaskTypes() []string

TaskTypes returns the worker's supported task types as list of strings.

type WorkerTag

type WorkerTag struct {
	Model

	UUID        string `gorm:"type:char(36);default:'';unique;index"`
	Name        string `gorm:"type:varchar(64);default:'';unique"`
	Description string `gorm:"type:varchar(255);default:''"`

	Workers []*Worker `gorm:"many2many:worker_tag_membership;constraint:OnDelete:CASCADE"`
}

type WorkerTestFixture

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

Jump to

Keyboard shortcuts

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