gitea: code.gitea.io/gitea/modules/cron Index | Files

package cron

import "code.gitea.io/gitea/modules/cron"

Index

Package Files

cron.go setting.go tasks.go tasks_basic.go tasks_extended.go

func NewContext Uses

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 Uses

func RegisterTask(name string, config Config, fun func(context.Context, *models.User, Config) error) error

RegisterTask allows a task to be registered with the cron service

func RegisterTaskFatal Uses

func RegisterTaskFatal(name string, config Config, fun func(context.Context, *models.User, Config) error)

RegisterTaskFatal will register a task but if there is an error log.Fatal

type BaseConfig Uses

type BaseConfig struct {
    Enabled         bool
    RunAtStart      bool
    Schedule        string
    NoSuccessNotice bool
}

BaseConfig represents the basic config for a Cron task

func (*BaseConfig) DoNoticeOnSuccess Uses

func (b *BaseConfig) DoNoticeOnSuccess() bool

DoNoticeOnSuccess returns whether a success notice should be posted

func (*BaseConfig) DoRunAtStart Uses

func (b *BaseConfig) DoRunAtStart() bool

DoRunAtStart returns whether the task should be run at the start

func (*BaseConfig) FormatMessage Uses

func (b *BaseConfig) FormatMessage(name, status string, doer *models.User, args ...interface{}) string

FormatMessage returns a message for the task

func (*BaseConfig) GetSchedule Uses

func (b *BaseConfig) GetSchedule() string

GetSchedule returns the schedule for the base config

func (*BaseConfig) IsEnabled Uses

func (b *BaseConfig) IsEnabled() bool

IsEnabled returns the enabled status for the config

type Config Uses

type Config interface {
    IsEnabled() bool
    DoRunAtStart() bool
    GetSchedule() string
    FormatMessage(name, status string, doer *models.User, args ...interface{}) string
    DoNoticeOnSuccess() bool
}

Config represents a basic configuration interface that cron task

type OlderThanConfig Uses

type OlderThanConfig struct {
    BaseConfig
    OlderThan time.Duration
}

OlderThanConfig represents a cron task with OlderThan setting

type Task Uses

type Task struct {
    Name string

    ExecTimes int64
    // contains filtered or unexported fields
}

Task represents a Cron task

func GetTask Uses

func GetTask(name string) *Task

GetTask gets the named task

func (*Task) DoRunAtStart Uses

func (t *Task) DoRunAtStart() bool

DoRunAtStart returns if this task should run at the start

func (*Task) GetConfig Uses

func (t *Task) GetConfig() Config

GetConfig will return a copy of the task's config

func (*Task) IsEnabled Uses

func (t *Task) IsEnabled() bool

IsEnabled returns if this task is enabled as cron task

func (*Task) Run Uses

func (t *Task) Run()

Run will run the task incrementing the cron counter with no user defined

func (*Task) RunWithUser Uses

func (t *Task) RunWithUser(doer *models.User, config Config)

RunWithUser will run the task incrementing the cron counter at the time with User

type TaskTable Uses

type TaskTable []*TaskTableRow

TaskTable represents a table of tasks

func ListTasks Uses

func ListTasks() TaskTable

ListTasks returns all running cron tasks.

type TaskTableRow Uses

type TaskTableRow struct {
    Name      string
    Spec      string
    Next      time.Time
    Prev      time.Time
    ExecTimes int64
}

TaskTableRow represents a task row in the tasks table

type UpdateExistingConfig Uses

type UpdateExistingConfig struct {
    BaseConfig
    UpdateExisting bool
}

UpdateExistingConfig represents a cron task with UpdateExisting setting

Package cron imports 16 packages (graph) and is imported by 58 packages. Updated 2020-12-30. Refresh now. Tools for package owners.