schedulingrecord

package
v0.0.0-...-e8a8f99 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NEW the record initialized status.
	NEW Status = "NEW"
	// RUNNABLE NEW->RUNNABLE / RUNNING->RUNNABLE.
	RUNNABLE = "RUNNABLE"
	// RUNNING RUNNABLE->RUNNING / RUNNING->RUNNABLE/ RUNNING -> FINISHED / RUNNING->FAILED.
	RUNNING = "RUNNING"
	// FINISHED RUNNING->FINISHED.
	FINISHED = "FINISHED"
	// FAILED RUNNING->FAILED.
	FAILED = "FAILED"
)

Variables

View Source
var SchedulingRecordColumns = struct {
	ID        string
	TaskID    string
	Status    string
	Message   string
	DeletedAt string
	CreatedAt string
	CreatedBy string
	UpdatedAt string
	UpdatedBy string
}{
	ID:        "id",
	TaskID:    "task_id",
	Status:    "status",
	Message:   "message",
	DeletedAt: "deleted_at",
	CreatedAt: "created_at",
	CreatedBy: "created_by",
	UpdatedAt: "updated_at",
	UpdatedBy: "updated_by",
}

SchedulingRecordColumns table field name.

Functions

func Create

func Create(record *SchedulingRecord) error

Create a single SchedulingRecord to db by *gorm.DBs

func Delete

func Delete(id uint64) error

Delete delete permanently. 永久删除

func DeleteAt

func DeleteAt(id uint64) error

DeleteAt delete softly. 软删除

func PaginateQuery

func PaginateQuery(p *models.Pagination) (models.Response, error)

PaginateQuery todo

func Save

func Save(record *SchedulingRecord) error

Save a single task will be stored to db Note: all the fields will be updated to db, includes default value.

func Updates

func Updates(record *SchedulingRecord) error

Updates updates from specific task that will not updating the zero value fields to db. 只能保存非零字段

func UpdatesFromMap

func UpdatesFromMap(id uint64, values map[string]interface{}) error

UpdatesFromMap updates from specific task that will not updating the zero value fields to db. 只能保存map包含字段

Types

type SchedulingRecord

type SchedulingRecord struct {
	ID        uint64 `gorm:"primaryKey,autoIncrement" json:"id" toml:"id" yaml:"id"`
	TaskID    uint64 `gorm:"column:task_id" json:"task_id" toml:"task_id" yaml:"task_id"`
	Status    Status `gorm:"column:status" json:"status" toml:"status" yaml:"status"`
	Message   string `gorm:"column:message" json:"message" toml:"message" yaml:"message"`
	DeletedAt uint64 `gorm:"column:deleted_at" json:"deleted_at" toml:"deleted_at" yaml:"deleted_at"`
	CreatedAt uint64 `gorm:"autoCreateTime:nano" json:"created_at" toml:"created_at" yaml:"created_at"`
	CreatedBy string `gorm:"column:created_by" json:"created_by,omitempty" toml:"created_by" yaml:"created_by,omitempty"`
	UpdatedAt uint64 `gorm:"autoUpdateTime:nano" json:"updated_at" toml:"updated_at" yaml:"updated_at"`
	UpdatedBy string `gorm:"column:updated_by" json:"updated_by,omitempty" toml:"updated_by" yaml:"updated_by,omitempty"`
}

SchedulingRecord is an object representing the database table.

func Get

func Get(id uint64) (*SchedulingRecord, error)

Get returns the task by specific id.

func GetExcludeDeleted

func GetExcludeDeleted(id uint64) (*SchedulingRecord, error)

GetExcludeDeleted returns the task that excludes inactived by specific id.

func (*SchedulingRecord) AfterCreate

func (r *SchedulingRecord) AfterCreate(tx *gorm.DB) (err error)

AfterCreate do somethings, e.g. debug log.

func (*SchedulingRecord) AfterUpdate

func (r *SchedulingRecord) AfterUpdate(tx *gorm.DB) (err error)

AfterUpdate do somethings, e.g. update other database in the same transcation. 在同一个事务中更新数据

func (*SchedulingRecord) BeforeUpdate

func (r *SchedulingRecord) BeforeUpdate(tx *gorm.DB) (err error)

BeforeUpdate do somethings, e.g. updating the updated_at value.

func (SchedulingRecord) TableName

func (SchedulingRecord) TableName() string

TableName 会将 SchedulingRecord 的表名重写为 `scheduling_records`

type Status

type Status string

Status new->runnable->running->finished/failed

type Tabler

type Tabler interface {
	TableName() string
}

Tabler defines the table name.

Jump to

Keyboard shortcuts

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