 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- func NewContext(original context.Context)
- func RegisterTask(name string, config Config, ...) error
- func RegisterTaskFatal(name string, config Config, ...)
- type BaseConfig
- type CleanupHookTaskConfig
- type Config
- type GCLFSConfig
- type OlderThanConfig
- type Task
- type TaskTable
- type TaskTableRow
- type UpdateExistingConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewContext ¶
NewContext begins cron tasks Each cron task is run within the shutdown context as a running server AtShutdown the cron server is stopped
func RegisterTask ¶
func RegisterTask(name string, config Config, fun func(context.Context, *user_model.User, Config) error) error
RegisterTask allows a task to be registered with the cron service
func RegisterTaskFatal ¶
func RegisterTaskFatal(name string, config Config, fun func(context.Context, *user_model.User, Config) error)
RegisterTaskFatal will register a task but if there is an error log.Fatal
Types ¶
type BaseConfig ¶
BaseConfig represents the basic config for a Cron task
func (*BaseConfig) DoNoticeOnSuccess ¶
func (b *BaseConfig) DoNoticeOnSuccess() bool
DoNoticeOnSuccess returns whether a success notice should be posted
func (*BaseConfig) DoRunAtStart ¶
func (b *BaseConfig) DoRunAtStart() bool
DoRunAtStart returns whether the task should be run at the start
func (*BaseConfig) FormatMessage ¶
func (b *BaseConfig) FormatMessage(locale translation.Locale, name, status, doer string, args ...any) string
FormatMessage returns a message for the task Please note the `status` string will be concatenated with `admin.dashboard.cron.` and `admin.dashboard.task.` to provide locale messages. Similarly `name` will be composed with `admin.dashboard.` to provide the locale name for the task.
func (*BaseConfig) GetSchedule ¶
func (b *BaseConfig) GetSchedule() string
GetSchedule returns the schedule for the base config
func (*BaseConfig) IsEnabled ¶
func (b *BaseConfig) IsEnabled() bool
IsEnabled returns the enabled status for the config
type CleanupHookTaskConfig ¶
type CleanupHookTaskConfig struct {
	BaseConfig
	CleanupType  string
	OlderThan    time.Duration
	NumberToKeep int
}
    CleanupHookTaskConfig represents a cron task with settings to cleanup hook_task
type Config ¶
type Config interface {
	IsEnabled() bool
	DoRunAtStart() bool
	GetSchedule() string
	FormatMessage(locale translation.Locale, name, status, doer string, args ...any) string
	DoNoticeOnSuccess() bool
}
    Config represents a basic configuration interface that cron task
type GCLFSConfig ¶ added in v1.24.5
type OlderThanConfig ¶
type OlderThanConfig struct {
	BaseConfig
	OlderThan time.Duration
}
    OlderThanConfig represents a cron task with OlderThan setting
type Task ¶
type Task struct {
	Name string
	Status      string
	LastMessage string
	LastDoer    string
	ExecTimes   int64
	// This stores the time of the last manual run of this task.
	LastRun time.Time
	// contains filtered or unexported fields
}
    Task represents a Cron task
func (*Task) DoRunAtStart ¶
DoRunAtStart returns if this task should run at the start
func (*Task) Run ¶
func (t *Task) Run()
Run will run the task incrementing the cron counter with no user defined
func (*Task) RunWithUser ¶
func (t *Task) RunWithUser(doer *user_model.User, config Config)
RunWithUser will run the task incrementing the cron counter at the time with User
type TaskTableRow ¶
type TaskTableRow struct {
	Name        string
	Spec        string
	Next        time.Time
	Prev        time.Time
	Status      string
	LastMessage string
	LastDoer    string
	ExecTimes   int64
	// contains filtered or unexported fields
}
    TaskTableRow represents a task row in the tasks table
func (*TaskTableRow) FormatLastMessage ¶ added in v1.17.0
func (t *TaskTableRow) FormatLastMessage(locale translation.Locale) string
type UpdateExistingConfig ¶
type UpdateExistingConfig struct {
	BaseConfig
	UpdateExisting bool
}
    UpdateExistingConfig represents a cron task with UpdateExisting setting