cron

package
v0.22.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CRONLock = make(chan bool, 1)
View Source
var InternalProcessTracker = NewProcessTracker()
View Source
var RunningLock = make(chan bool, 1)

Functions

func AddJobConfig

func AddJobConfig(job utils.CRONConfig)

func CancelJob

func CancelJob(scheduler string, jobName string) error

func CronConfigIdRoute added in v0.22.0

func CronConfigIdRoute(w http.ResponseWriter, req *http.Request)

CronConfigIdRoute godoc @Summary Get, update, or delete a CRON job configuration by name @Tags Cron @Accept json @Produce json @Param name path string true "CRON job name" @Param body body utils.CRONConfig false "Updated CRON config (PUT only)" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 404 {object} utils.HTTPErrorResult @Router /api/cron/{name} [get] @Router /api/cron/{name} [put] @Router /api/cron/{name} [delete]

func CronConfigRoute added in v0.22.0

func CronConfigRoute(w http.ResponseWriter, req *http.Request)

CronConfigRoute godoc @Summary List or create CRON job configurations @Tags Cron @Accept json @Produce json @Param body body utils.CRONConfig false "CRON config (POST only)" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 409 {object} utils.HTTPErrorResult @Router /api/cron [get] @Router /api/cron [post]

func DeleteJobRoute

func DeleteJobRoute(w http.ResponseWriter, req *http.Request)

DeleteJobRoute godoc @Summary Delete a job from the CRON configuration @Tags Cron @Accept json @Produce json @Param body body JobRequestJSON true "Job identifier" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/jobs/delete [post]

func DeregisterJob

func DeregisterJob(scheduler string, name string)

func GetJobRoute

func GetJobRoute(w http.ResponseWriter, req *http.Request)

GetJobRoute godoc @Summary Get details and logs of a specific job @Tags Cron @Accept json @Produce json @Param body body JobRequestJSON true "Job identifier" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Failure 404 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/jobs/get [post]

func GetJobsList

func GetJobsList() map[string]map[string]ConfigJob

func GetRunningJobsRoute added in v0.18.0

func GetRunningJobsRoute(w http.ResponseWriter, req *http.Request)

GetRunningJobsRoute godoc @Summary List currently running jobs @Tags Cron @Produce json @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Router /api/jobs/running [get]

func Init

func Init()

func InitJobs

func InitJobs()

func InitScheduler

func InitScheduler()

func JobFromCommand

func JobFromCommand(command string, args ...string) func(OnLog func(string), OnFail func(error), OnSuccess func(), ctx context.Context, cancel context.CancelFunc)

func JobFromCommandWithEnv added in v0.18.0

func JobFromCommandWithEnv(env []string, command string, args ...string) func(OnLog func(string), OnFail func(error), OnSuccess func(), ctx context.Context, cancel context.CancelFunc)

func JobFromContainerCommand

func JobFromContainerCommand(containerID string, command string, args ...string) func(OnLog func(string), OnFail func(error), OnSuccess func(), ctx context.Context, cancel context.CancelFunc)

func ListJobs

func ListJobs(w http.ResponseWriter, req *http.Request)

ListJobs godoc @Summary List all scheduled jobs @Tags Cron @Produce json @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Router /api/jobs [get]

func ManualRunJob

func ManualRunJob(scheduler string, name string) error

func RegisterJob

func RegisterJob(job ConfigJob)

func RemoveJobConfig

func RemoveJobConfig(name string)

func ResetScheduler

func ResetScheduler(scheduler string)

func RunJobRoute

func RunJobRoute(w http.ResponseWriter, req *http.Request)

RunJobRoute godoc @Summary Manually trigger a job to run @Tags Cron @Accept json @Produce json @Param body body JobRequestJSON true "Job identifier" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/jobs/run [post]

func RunOneTimeJob

func RunOneTimeJob(job ConfigJob)

func RunningJobs added in v0.18.0

func RunningJobs() []string

func StopJobRoute

func StopJobRoute(w http.ResponseWriter, req *http.Request)

StopJobRoute godoc @Summary Stop a running job @Tags Cron @Accept json @Produce json @Param body body JobRequestJSON true "Job identifier" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/jobs/stop [post]

func WaitForAllJobs added in v0.18.0

func WaitForAllJobs()

Types

type ConfigJob

type ConfigJob struct {
	Disabled       bool
	Scheduler      string
	Name           string
	Cancellable    bool
	Job            func(OnLog func(string), OnFail func(error), OnSuccess func(), ctx context.Context, cancel context.CancelFunc) `json:"-"`
	Crontab        string
	Running        bool
	LastStarted    time.Time
	LastRun        time.Time
	LastRunSuccess bool
	Logs           []string
	Ctx            context.Context    `json:"-"`
	CancelFunc     context.CancelFunc `json:"-"`
	Container      string
	Timeout        time.Duration
	MaxLogs        int
	Resource       string
}

type ExecuterFn added in v0.18.0

type ExecuterFn func(OnLog func(string), OnFail func(error), OnSuccess func(), ctx context.Context, cancel context.CancelFunc)

type JobRequestJSON

type JobRequestJSON struct {
	Scheduler string `validate:"required,min=3,max=32,alphanum"`
	Name      string `validate:"required,min=3,max=32,alphanum"`
}

type ProcessTracker added in v0.18.0

type ProcessTracker struct {
	// contains filtered or unexported fields
}

func NewProcessTracker added in v0.18.0

func NewProcessTracker() *ProcessTracker

func (*ProcessTracker) EndProcess added in v0.18.0

func (pt *ProcessTracker) EndProcess()

func (*ProcessTracker) StartProcess added in v0.18.0

func (pt *ProcessTracker) StartProcess()

func (*ProcessTracker) WaitForZero added in v0.18.0

func (pt *ProcessTracker) WaitForZero()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL