Documentation ¶
Index ¶
Constants ¶
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 ¶
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 ¶
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.
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
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 ¶
LabelSet is a type alias for label.Set. It adds some extra methods for gorm to scan and convert values.
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