model

package
v0.0.0-...-ea35677 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// noop is reserved for some unexpected scenario, such as job operation of
	// a nonexistent job
	JobOpStatusNoop      = JobOpStatus(1)
	JobOpStatusCanceling = JobOpStatus(2)
	JobOpStatusCanceled  = JobOpStatus(3)
)

Defines all JobOpStatus

Variables

View Source
var JobOpUpdateColumns = []string{
	"updated_at",
	"op",
	"job_id",
}

JobOpUpdateColumns is used in gorm update. TODO: using reflect to generate it more generally related to some implement of gorm

Functions

func NewEpochClient

func NewEpochClient(jobID string, db *gorm.DB) (*epochClient, error)

NewEpochClient news a EpochClient Make Sure to call 'InitEpochModel' to create backend table before calling 'NewEpochClient'

Types

type EpochClient

type EpochClient interface {
	// GenEpoch increases the backend epoch by 1 and return the new epoch
	// Guarantee to be thread-safe
	GenEpoch(ctx context.Context) (int64, error)

	// Close releases some inner resources
	Close() error
}

EpochClient defines the client to generate epoch

type Executor

type Executor struct {
	Model
	ID      engineModel.ExecutorID `json:"id" gorm:"column:id;type:varchar(256) not null;uniqueIndex:uni_id"`
	Name    string                 `json:"name" gorm:"column:name;type:varchar(256) not null"`
	Address string                 `json:"address" gorm:"column:address;type:varchar(256) not null"`

	// Labels store the label set for each executor.
	Labels LabelSet `json:"labels" gorm:"column:labels;type:json"`
}

Executor records the information of an executor.

func (*Executor) Map

func (e *Executor) Map() map[string]interface{}

Map is used in gorm update.

type JobOp

type JobOp struct {
	Model
	Op    JobOpStatus `gorm:"type:tinyint not null;index:idx_job_op,priority:2;comment:Canceling(1),Canceled(2)"`
	JobID string      `gorm:"type:varchar(128) not null;uniqueIndex:uk_job_id"`
}

JobOp stores job operation recoreds

func (*JobOp) Map

func (op *JobOp) Map() map[string]interface{}

Map is used for update in orm model

type JobOpStatus

type JobOpStatus int8

JobOpStatus represents the expected status of a job, note this status diffs from the worker status defined in framework model, the relationship of these two status system is as follows. - JobOpStatusCanceling, no mapping - JobOpStatusCanceled maps to WorkerStatusStopped

type KeyValueMap

type KeyValueMap = map[string]interface{}

KeyValueMap alias to key value map when updating data in gorm

type LabelSet

type LabelSet label.Set

LabelSet is a type alias for label.Set. It adds some extra methods for gorm to scan and convert values.

func (*LabelSet) Scan

func (s *LabelSet) Scan(rawInput interface{}) error

Scan implements the sql.Scanner interface.

func (LabelSet) ToMap

func (s LabelSet) ToMap() map[string]string

ToMap converts a LabelSet to a plain map.

func (LabelSet) Value

func (s LabelSet) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type LogicEpoch

type LogicEpoch struct {
	Model
	JobID string `gorm:"type:varchar(128) not null;uniqueIndex:uidx_jk"`
	Epoch int64  `gorm:"type:bigint not null default 1"`
}

LogicEpoch is used to generate increasing epoch We use union columns <JobID, Epoch> as uk to achieve job-level isolation

type Model

type Model struct {
	SeqID     uint      `json:"seq-id" gorm:"primaryKey;autoIncrement"`
	CreatedAt time.Time `json:"created-at"`
	UpdatedAt time.Time `json:"updated-at"`
}

Model defines basic fileds used in gorm CreatedAt/UpdatedAt will autoupdate in the gorm lib, not in sql backend

type ProjectInfo

type ProjectInfo struct {
	Model
	ID   string `gorm:"column:id;type:varchar(128) not null;uniqueIndex:uidx_id"`
	Name string `gorm:"type:varchar(128) not null"`
}

ProjectInfo for Multi-projects support

type ProjectOperation

type ProjectOperation struct {
	SeqID     uint      `gorm:"primaryKey;auto_increment"`
	ProjectID string    `gorm:"type:varchar(128) not null;index:idx_op"`
	Operation string    `gorm:"type:varchar(16) not null"`
	JobID     string    `gorm:"type:varchar(128) not null"`
	CreatedAt time.Time `gorm:"autoCreateTime;index:idx_op"`
}

ProjectOperation records each operation of a project

Jump to

Keyboard shortcuts

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