granitic: Index | Files

package schedule

import ""


Package Files

controltask.go error.go invocation.go manager.go parse.go schedule.go scheduler.go task.go


const (
    //Scheduled indicates that this is the invocation was due to a schedule
    Scheduled = "Scheduled"
    //Retry indicates that this is the invocation is a retry of a previously failed invocation
    Retry = "Retry"
    //Manual indicates that this is the invocation was triggered outside of a schedule
    Manual = "Manual"
const (
    //OffsetFromStart indicates the interval between invocations is relative to the time the application started
    OffsetFromStart intervalMode = iota

    //ActualStartTime indicates that the invocation will run at a specified time
const (
    //LLComponentName is the name of the component that handles the management of scheduled tasks
    LLComponentName = instance.FrameworkPrefix + "CommandScheduledTasks"

func NewAllowRetryErrorf Uses

func NewAllowRetryErrorf(template string, args ...interface{}) error

NewAllowRetryErrorf creates a an AllowRetryError with the supplied message

type AllowRetryError Uses

type AllowRetryError struct {
    // contains filtered or unexported fields

AllowRetryError indicates a non-fatal problem that means retrying the task is permissible

func (*AllowRetryError) Error Uses

func (e *AllowRetryError) Error() string

Error returns the error message

type Task Uses

type Task struct {

    // A human-readable name for the task
    Name string
    // An optional unique ID for the task (the IoC component name for this task will be used if not specified)
    ID  string
    // The name of the IoC component implementing TaskLogic that actually performs this task
    Component string
    // The maximum number of overlapping instances of the task that are allowed to run. Zero means only one instance of this task can run at a time
    MaxOverlapping int
    // If set to true, suppress warning messages being logged when a task is scheduled to run while another instance is already running
    NoWarnOnOverlap bool
    // A human-readable expression (in English) of how frequently the task should be run - see package docs
    Every string

    // If set to true, any status updates messages sent from the task to the scheduler will be logged
    LogStatusMessages bool

    // The name of a component that is interested in receiving status updates from a running task
    StatusUpdateReceiver string

    // If set to true the task will never run
    Disabled bool

    // The number of times an invocation of this task should be re-tried if the task fails with an AllowRetryError
    MaxRetries int

    // A human-readable expression (in English) of how the interval to wait between a failure and a retry (e.g. 1 minute, 20 seconds)
    // Must be set if MaxRetries > 0
    RetryInterval string
    // contains filtered or unexported fields

Task describes when and how frequently a scheduled task should be executed and the component that provides a method to actually perform the task

func (*Task) FullName Uses

func (t *Task) FullName() string

FullName returns either task name + ID, just task name or just ID depending on which fields are set

type TaskInvocationSummary Uses

type TaskInvocationSummary struct {
    TaskName        string
    TaskID          string
    StartedAt       time.Time
    InvocationCount uint64

TaskInvocationSummary meta-data about a task invocation

type TaskLogic Uses

type TaskLogic interface {
    ExecuteTask(c chan TaskStatusUpdate) error

TaskLogic is implemented by any component that can be invoked via a scheduled task

type TaskScheduler Uses

type TaskScheduler struct {
    State ioc.ComponentState
    // Logger used by Granitic framework components. Automatically injected.
    FrameworkLogger     logging.Logger
    FrameworkLogManager *logging.ComponentLoggerManager
    // contains filtered or unexported fields

TaskScheduler is the top level Granitic component for managing the scheduled invocation of tasks

func (*TaskScheduler) AllowAccess Uses

func (ts *TaskScheduler) AllowAccess() error

AllowAccess spawns a goroutinue managing each scheduled task

func (*TaskScheduler) Container Uses

func (ts *TaskScheduler) Container(container *ioc.ComponentContainer)

Container implements ioc.ContainerAccessor.Container

func (*TaskScheduler) PrepareToStop Uses

func (ts *TaskScheduler) PrepareToStop()

PrepareToStop calls the same method of each of the managed Tasks

func (*TaskScheduler) ReadyToStop Uses

func (ts *TaskScheduler) ReadyToStop() (bool, error)

ReadyToStop only returns true when each of the managed tasks report that they are ReadyToStop

func (*TaskScheduler) StartComponent Uses

func (ts *TaskScheduler) StartComponent() error

StartComponent Finds any schedules, parses them and verifies the component they reference implements schedule.TaskLogic

func (*TaskScheduler) Stop Uses

func (ts *TaskScheduler) Stop() error

Stop calls the same method on each of the managed tasks. Any errors returned when stopping the underlying tasks are concatenated together and returned as a single error

type TaskStatusUpdate Uses

type TaskStatusUpdate struct {
    Message string
    Status  interface{}

TaskStatusUpdate allows a task to communicate back to its manager some status.

func StatusMessagef Uses

func StatusMessagef(format string, a ...interface{}) TaskStatusUpdate

StatusMessagef creates a TaskStatusUpdate with the supplied message

type TaskStatusUpdateReceiver Uses

type TaskStatusUpdateReceiver interface {
    Receive(summary TaskInvocationSummary, update TaskStatusUpdate)

TaskStatusUpdateReceiver is implemented by a component that wants to receive status updates about an invocation of a task

Package schedule imports 11 packages (graph). Updated 2020-05-26. Refresh now. Tools for package owners.