Documentation ¶
Index ¶
- Constants
- Variables
- func Create(task *Task) error
- func Delete(id uint64) error
- func DeleteAt(id uint64) error
- func PaginateQuery(p *models.Pagination) (models.Response, error)
- func Save(task *Task) error
- func Updates(task *Task) error
- func UpdatesFromMap(id uint64, values map[string]interface{}) error
- type Executor
- type SchedulingCategory
- type Status
- type Tabler
- type Task
- type Type
Constants ¶
const ( // PENDING initialization status. PENDING Status = "PENDING" // ENABLED wirking status. ENABLED = "ENABLED" // DISABLED discarded status. DISABLED = "DISABLED" )
const ( // KAFKA from kafka KAFKA Executor = "KAFKA" // RPC from rpc service RPC = "RPC" // HTTP from http app HTTP = "HTTP" )
Variables ¶
var TaskColumns = struct { ID string Name string Code string Type string Status string ExpiredAt string Cron string Timeout string SchedulingCategory string Executor string DeletedAt string CreatedAt string CreatedBy string UpdatedAt string UpdatedBy string }{ ID: "id", Name: "name", Code: "code", Type: "type", Status: "status", ExpiredAt: "expired_at", Cron: "cron", Timeout: "timeout", SchedulingCategory: "scheduling_category", Executor: "executor", DeletedAt: "deleted_at", CreatedAt: "created_at", CreatedBy: "created_by", UpdatedAt: "updated_at", UpdatedBy: "updated_by", }
TaskColumns table field name.
Functions ¶
func PaginateQuery ¶
func PaginateQuery(p *models.Pagination) (models.Response, error)
PaginateQuery todo
func Save ¶
Save a single task will be stored to db Note: all the fields will be updated to db, includes default value.
func Updates ¶
Updates updates from specific task that will not updating the zero value fields to db. 只能保存非零字段
func UpdatesFromMap ¶
UpdatesFromMap updates from specific task that will not updating the zero value fields to db. 只能保存map包含字段
Types ¶
type SchedulingCategory ¶
type SchedulingCategory string
SchedulingCategory categories.
const ( // SINGLETON scheduling one node. SINGLETON SchedulingCategory = "SINGLETON" // MULTIPLE scheduling more nodes. MULTIPLE = "MULTIPLE" )
type Task ¶
type Task struct { ID uint64 `gorm:"primaryKey,autoIncrement" json:"id" toml:"id" yaml:"id"` Name string `gorm:"column:name" json:"name" toml:"name" yaml:"name"` Code string `gorm:"column:code" json:"code" toml:"code" yaml:"code"` Type Type `gorm:"embedded,column:type" json:"type" toml:"type" yaml:"type"` Status Status `gorm:"column:status" json:"status" toml:"status" yaml:"status"` ExpiredAt uint64 `gorm:"column:expired_at" json:"expired_at" toml:"expired_at" yaml:"expired_at"` Cron string `gorm:"column:cron" json:"cron,omitempty" toml:"cron" yaml:"cron,omitempty"` Timeout int `gorm:"column:timeout" json:"timeout" toml:"timeout" yaml:"timeout"` SchedulingCategory SchedulingCategory `gorm:"column:scheduling_category" json:"scheduling_category" toml:"scheduling_category" yaml:"scheduling_category"` Executor Executor `gorm:"column:executor" json:"executor" toml:"executor" yaml:"executor"` 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"` }
Task is an object representing the database table.
func GetExcludeDeleted ¶
GetExcludeDeleted returns the task that excludes inactived by specific id.
func (*Task) AfterCreate ¶
AfterCreate do somethings, e.g. debug log.
func (*Task) AfterUpdate ¶
AfterUpdate do somethings, e.g. update other database in the same transcation. 在同一个事务中更新数据
func (*Task) BeforeCreate ¶
BeforeCreate do somethings, e.g. checks for the necessary fields.
func (*Task) BeforeUpdate ¶
BeforeUpdate do somethings, e.g. updating the updated_at value.