Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteTask(id string)
- func IsEnded(status string) bool
- func MustGetString(ctx context.Context, key string) string
- func RegisterScheduleTask(task ScheduleTask) (taskID string)
- func RunTasks()
- func RunWithContext(tag string, f func(ctx context.Context) error, ctxInput context.Context) (taskID string)
- func RunWithinGroup(groupName string, f func(ctx context.Context) error) (taskID string)
- func StartTask(id string)
- func StopAllTasks()
- func StopTask(id string)
- func StopTasks()
- type Metadata
- type ScheduleTask
- type State
- type Task
- type TaskResult
Constants ¶
View Source
const ( StatusRunning = "running" StatusComplete = "complete" StatusError = "error" StatusReady = "ready" StatusInit = "init" StatusPendingStop = "pending_stop" StatusStopped = "stopped" )
View Source
const ( Pending State = "PENDING" Running State = "STARTED" Canceled = "CANCELED" Finished = "FINISHED" )
View Source
const Crontab = "crontab"
View Source
const Interval = "interval"
View Source
const Transient = "transient"
Variables ¶
View Source
var Tasks = sync.Map{}
Functions ¶
func DeleteTask ¶
func DeleteTask(id string)
func RegisterScheduleTask ¶
func RegisterScheduleTask(task ScheduleTask) (taskID string)
func RunWithContext ¶
func RunWithinGroup ¶
func StopAllTasks ¶
func StopAllTasks()
Types ¶
type ScheduleTask ¶
type ScheduleTask struct { ID string `config:"id" json:"id,omitempty"` Group string `config:"group" json:"group,omitempty"` Description string `config:"description" json:"description,omitempty"` Type string `config:"type" json:"type,omitempty"` Interval string `config:"interval" json:"interval,omitempty"` Crontab string `config:"crontab" json:"crontab,omitempty"` CreateTime time.Time `config:"create_time" json:"create_time,omitempty"` StartTime *time.Time `config:"start_time" json:"start_time,omitempty"` EndTime *time.Time `config:"end_time" json:"end_time,omitempty"` // Ensures the task runs as a singleton, preventing duplicate executions when previous attempt is not finished. Singleton bool `config:"singleton" json:"singleton,omitempty"` Task func(ctx context.Context) `config:"-" json:"-"` State State `config:"state" json:"state,omitempty"` Ctx context.Context `config:"-" json:"-"` //for transient task // contains filtered or unexported fields }
type Task ¶
type Task struct { orm.ORMObjectBase ParentId []string `json:"parent_id,omitempty" elastic_mapping:"parent_id: { type: keyword }"` StartTimeInMillis int64 `json:"start_time_in_millis" elastic_mapping:"start_time_in_millis: { type: long }"` Cancellable bool `json:"cancellable" elastic_mapping:"cancellable: { type: boolean }"` Runnable bool `json:"runnable" elastic_mapping:"runnable: { type: boolean }"` Metadata Metadata `json:"metadata" elastic_mapping:"metadata: { type: object }"` Status string `json:"status" elastic_mapping:"status: { type: keyword }"` Description string `json:"description,omitempty" elastic_mapping:"description: { type: text }"` ConfigString string `json:"config_string" elastic_mapping:"config_string:{ type: text }"` CompletedTime *time.Time `json:"completed_time,omitempty" elastic_mapping:"completed_time: { type: date }"` RetryTimes int `json:"retry_times,omitempty" elastic_mapping:"retry_times: { type: integer }"` // DEPRECATED: used by old tasks Config_ interface{} `json:"config,omitempty" elastic_mapping:"config:{type: object,enabled:false }"` }
type TaskResult ¶
Click to show internal directories.
Click to hide internal directories.