Documentation
¶
Index ¶
Constants ¶
View Source
const ( EventTypeInfo = "info" EventTypeWarning = "warning" EventTypeText = "text" )
View Source
const ( JobStatusQueuing = "queuing" JobStatusCanceled = "canceled" JobStatusSent = "sent" JobStatusRunning = "running" JobStatusExpired = "expired" JobStatusSucceeded = "succeeded" JobStatusFailed = "failed" )
Variables ¶
View Source
var RESERVED = xtype.Strings{"agent", "status", "help", "delay", "group"}
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
ID string `json:"id" gorm:"type:varchar(20);primary_key"`
Secret string `json:"-" gorm:"type:varchar(20);index"`
UserID string `json:"user_id" gorm:"type:varchar(20);index:idx_uid;uniqueIndex:idx_un1;uniqueIndex:idx_un2"`
Name string `json:"name" gorm:"type:varchar(50);uniqueIndex:idx_un1"`
Alias string `json:"alias" gorm:"type:varchar(50);uniqueIndex:idx_un2"`
Remark string `json:"remark"`
// IP address last connected from
IP string `json:"ip" gorm:"type:varchar(50)"`
// Only update after a agent offline, means last activated at that time.
ActivatedAt *time.Time `json:"activated_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Agent belongs to user, have id and secret, saved in db.
type AgentBasic ¶
type AgentBasic struct {
Name string `json:"name"`
Alias string `json:"alias"`
Remark string `json:"remark"`
}
AgentBasic used for agent creation ui
type EventCenter ¶
type EventHandler ¶
type EventHandler func(e *Event)
EventHandler handle the event, and please handle the error yourself.
type EventInput ¶
type EventInput struct {
Message string `json:"message"`
}
type Job ¶
type Job struct {
ID string `json:"id" gorm:"type:varchar(20);primary_key"`
JobInput
// queuing/canceled/sent/expired/succeeded/failed
Status string `json:"status" gorm:"type:varchar(10)"`
// agent returned, job log or other message
Result string `json:"result" gorm:"type:varchar(1024)"`
CreatedAt time.Time `json:"created_at" gorm:"index:by_user;index:by_agent"`
SentAt *time.Time `json:"sent_at,omitempty"`
CanceledAt *time.Time `json:"canceled_at,omitempty"`
ExpiredAt *time.Time `json:"expired_at,omitempty"`
SucceededAt *time.Time `json:"succeeded_at,omitempty"`
FailedAt *time.Time `json:"failed_at,omitempty"`
}
Job will be saved in db, it's a gorm mysql model
type JobInput ¶
type JobInput struct {
UserID string `json:"user_id" gorm:"type:varchar(20);index:by_user"`
AgentID string `json:"agent_id" gorm:"type:varchar(20);index:by_agent"`
// job payload
Message string `json:"message" gorm:"type:varchar(255)"`
// source context, any string defined by source
Source string `json:"source" gorm:"type:varchar(255)"`
// callback url, will be called after expired/succeeded/failed
Callback string `json:"callback" gorm:"type:varchar(255)"`
}
JobInput is input fields which upstream service passed
Click to show internal directories.
Click to hide internal directories.