cron

package
v2.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusNew     = 100 // Job has not run
	StatusRunning = 101

	// Codes for temorarily stopped jobs
	StatusStopped       = 200
	StatusStoppedSystem = 201
	StatusStoppedUser   = 202

	// Codes that indicates jobs that have run until completeion
	StatusDone         = 300
	StatusExpiredCount = 301
	StatusExpiredDate  = 302
	StatusDeleted      = 303

	StatusFailed = 500
)

Status codes for jobs

View Source
const ConfigDeletePushTokenOnSendError = true

ConfigDeletePushTokenOnSendError sets if tokens that have error on send are deleted from the database.

View Source
const CronContextName = "CRON"

CronContextName holds the cron service in gin context objects

Variables

This section is empty.

Functions

func CronInserter

func CronInserter(cron *CronSender) gin.HandlerFunc

CronInserter is a gin middleware that will insert a CronSender driver into the context.

func IsExpired

func IsExpired(job *models.Cronbox) bool

IsExpired return true if a cronjob has expired.

func SecureRandomAlphaString

func SecureRandomAlphaString(length int) string

TODO: Duplicated from helper.go

func SecureRandomBytes

func SecureRandomBytes(length int) []byte

SecureRandomBytes returns the requested number of bytes using crypto/rand

Types

type CronSender

type CronSender struct {
	DbMap     *gorp.DbMap
	FcmClient *messaging.Client
	// contains filtered or unexported fields
}

CronSender is a Gin middleware for sending and storing delayed and repeated messages

func (*CronSender) DeleteScheduledMessage

func (cs *CronSender) DeleteScheduledMessage(jobID int) (*models.Cronbox, error)

DeleteScheduledMessage removed a job from the cron scheduler.

func (*CronSender) GetCronbox

func (cs *CronSender) GetCronbox(JobID int) *models.Cronbox

GetCronbox returns the cronbox identified by jobid, or nil if it cannot be found.

func (*CronSender) GetCronboxes

func (cs *CronSender) GetCronboxes(owner string) ([]models.Cronbox, error)

GetCronboxes returns all cronbox jobs for owner.

func (*CronSender) GetMessage

func (cs *CronSender) GetMessage(JobID int) *models.Message

GetMessage returns the cronbox identified by jobid, or nil if it cannot be found.

func (*CronSender) InitializeFromDB

func (cs *CronSender) InitializeFromDB() error

InitializeFromDB loads jobs from database and into memory.

func (*CronSender) ScheduleMessage

func (cs *CronSender) ScheduleMessage(schedule string, timezone string, expire time.Time, repetitions int, owner string, message *models.Message) (*models.Cronbox, error)

ScheduleMessage will send the given message according to given schedule. The function will fail if the message is not present in the database. Return the jobid of the scheduled job.

func (*CronSender) StartCronbox

func (cs *CronSender) StartCronbox(JobID int) *models.Cronbox

StartCronbox sets cronbox state to running

func (*CronSender) StopCronbox

func (cs *CronSender) StopCronbox(JobID int) *models.Cronbox

StopCronbox sets cronbox state to stopped

func (*CronSender) StopScheduledMessage

func (cs *CronSender) StopScheduledMessage(jobID int) (*models.Cronbox, error)

StopScheduledMessage executing a job.

Jump to

Keyboard shortcuts

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