cron

package
v0.0.0-...-9551212 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound        = errors.New("cron job not found")
	ErrAlreadyEnabled  = errors.New("cron job already enabled")
	ErrAlreadyDisabled = errors.New("cron job already disabled")
	ErrAlreadyExists   = errors.New("cron job already exists")
)

Functions

func WithLogger

func WithLogger(shouldLog bool) cron.Logger

Types

type CronOptions

type CronOptions struct {
	Name   string
	RunNow bool
	Spec   string
	Cmd    func()
}

type Manager

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

Manager: A struct that manages cron jobs

func NewManager

func NewManager(ctx context.Context, logExec bool) *Manager

NewManager: Creates a new cron manager

func (*Manager) Add

func (m *Manager) Add(opts CronOptions) error

Add: Adds a cron job to the manager

func (*Manager) Disable

func (m *Manager) Disable(name string) error

Disable: Disable a previously enabled cron job

func (*Manager) Enable

func (m *Manager) Enable(name string) error

Enable: Enable a previously disabled cron job

func (*Manager) Remove

func (m *Manager) Remove(name string) error

Remove: Removes a cron job from the manager

func (*Manager) Start

func (m *Manager) Start()

Start: Starts the cron manager

func (*Manager) Stop

func (m *Manager) Stop()

Stop: Stops the cron manager

type WeakWrapper

type WeakWrapper interface {
	// GetID: Returns the ID of the cron job
	GetID() cron.EntryID
	// SetID: Sets the ID of the cron job
	SetID(id cron.EntryID)
	// Schedule: The schedule of the cron job
	Schedule() string
	// Code: The code of the cron job
	Code() func()
	// IsEnabled: Whether or not the cron job is enabled
	IsEnabled() bool
	// IsDisabled: Whether or not the cron job is disabled
	IsDisabled() bool
	// SetStatus: Sets the status of the cron job
	SetStatus(status bool)
}

WeakWrapper is a wrapper for a specified cron job

func NewWeakWrapper

func NewWeakWrapper(name, schedule string, id cron.EntryID, cmd func()) WeakWrapper

Jump to

Keyboard shortcuts

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