cron

package
v1.4.5-alpha1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2019 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package cron is a utility to schedule tasks. These tasks maybe scheduled for a specific time, they may be repeatable or intended to be run immediately. There are several API Endpoints which allow a developer to interact with the scheduling system.

It is important to understand several concepts.

<b>Task</b> - a job which can be scheduled to run at a specific time <b>Schedule</b> - a listing of all active tasks, when they will be executed and their respective metadata

The API allows you to:

  • Obtain a list of the currently scheduled tasks
  • Create a task to be run on a schedule
  • Obtain a list of possible tasks to be scheduled
  • Enable a task to be run on a schedule
  • Disable a task
  • Update the specified task
  • Run the specified task now

//TODO: add link to api documentation

Index

Constants

View Source
const (
	ConstErrorModule = "env/cron"
	ConstErrorLevel  = env.ConstErrorLevelService
)

Package global constants

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultCronSchedule

type DefaultCronSchedule struct {
	CronExpr string
	TaskName string
	Params   map[string]interface{}
	Repeat   bool
	Time     time.Time
	// contains filtered or unexported fields
}

DefaultCronSchedule structure to hold schedule information (for internal usage)

func (*DefaultCronSchedule) Disable

func (it *DefaultCronSchedule) Disable() error

Disable - disables schedule

func (*DefaultCronSchedule) Enable

func (it *DefaultCronSchedule) Enable() error

Enable - enable schedule

func (*DefaultCronSchedule) Execute

func (it *DefaultCronSchedule) Execute()

Execute - execute a scheduled task

func (*DefaultCronSchedule) Get

func (it *DefaultCronSchedule) Get(param string) interface{}

Get return - specified param value

func (*DefaultCronSchedule) GetInfo

func (it *DefaultCronSchedule) GetInfo() map[string]interface{}

GetInfo - return set of settings for schedule

func (*DefaultCronSchedule) RunTask

func (it *DefaultCronSchedule) RunTask(params map[string]interface{}) error

RunTask - execute a task of schedule without changing of schedule to execute with empty params you should use RunTask(make(map[string]interface{}) otherwise schedule params will be used

func (*DefaultCronSchedule) Set

func (it *DefaultCronSchedule) Set(param string, value interface{}) error

Set - set param for DefaultCronSchedule

type DefaultCronScheduler

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

DefaultCronScheduler is a default implementer of InterfaceIniConfig

func (*DefaultCronScheduler) ListSchedules

func (it *DefaultCronScheduler) ListSchedules() []env.InterfaceSchedule

ListSchedules returns list of currently registered schedules

func (*DefaultCronScheduler) ListTasks

func (it *DefaultCronScheduler) ListTasks() []string

ListTasks returns a list of task names currently available

func (*DefaultCronScheduler) RegisterTask

func (it *DefaultCronScheduler) RegisterTask(name string, task env.FuncCronTask) error

RegisterTask registers a new task routine by a given task name

  • returns error no non unique name

func (*DefaultCronScheduler) ScheduleAtTime

func (it *DefaultCronScheduler) ScheduleAtTime(scheduleTime time.Time, taskName string, params map[string]interface{}) (env.InterfaceSchedule, error)

ScheduleAtTime schedules task execution once with a given params

func (*DefaultCronScheduler) ScheduleOnce

func (it *DefaultCronScheduler) ScheduleOnce(cronExpr string, taskName string, params map[string]interface{}) (env.InterfaceSchedule, error)

ScheduleOnce schedules task execution with a given params

func (*DefaultCronScheduler) ScheduleRepeat

func (it *DefaultCronScheduler) ScheduleRepeat(cronExpr string, taskName string, params map[string]interface{}) (env.InterfaceSchedule, error)

ScheduleRepeat schedules task execution with a given params

Jump to

Keyboard shortcuts

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