Documentation ¶
Index ¶
- Constants
- func CronInserter(cron *CronSender) gin.HandlerFunc
- func DbDeleteCronbox(tx gorp.SqlExecutor, cb models.Cronbox) (bool, error)
- func DbDeleteCronboxAndTemplate(tx gorp.SqlExecutor, cb models.Cronbox) (bool, error)
- func DbDeleteMessage(tx gorp.SqlExecutor, m models.Message) (bool, error)
- func DbDeleteMessageId(tx gorp.SqlExecutor, messageID string) (bool, error)
- func DbGetCronboxByJobID(tx gorp.SqlExecutor, id models.JobID) (*models.Cronbox, error)
- func DbGetCronboxesForAll(tx gorp.SqlExecutor) ([]models.Cronbox, error)
- func DbGetCronboxesForOwner(tx gorp.SqlExecutor, owner models.OwnerID) ([]models.Cronbox, error)
- func DbGetJobTemplate(tx gorp.SqlExecutor, jobId models.JobID) (*models.Message, error)
- func DbGetMessageByID(tx gorp.SqlExecutor, id string) (*models.Message, error)
- func DbUpdateCronbox(tx gorp.SqlExecutor, cb models.Cronbox) (bool, error)
- func IsExpired(job *models.Cronbox) bool
- func IsRunnable(job *models.Cronbox) bool
- func SecureRandomAlphaString(length int) string
- func SecureRandomBytes(length int) []byte
- type CronSender
- func (cs *CronSender) DeleteScheduledMessage(jobID models.JobID) (bool, error)
- func (cs *CronSender) GetCronboxes(owner models.OwnerID) ([]models.Cronbox, error)
- func (cs *CronSender) InitializeFromDB() error
- func (cs *CronSender) ScheduleMessage(schedule string, timezone string, expire time.Time, repetitions int, ...) (*models.Cronbox, error)
- func (cs *CronSender) StartCronbox(JobID models.JobID) error
- func (cs *CronSender) StopCronbox(JobID models.JobID, status int) error
Constants ¶
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
const ConfigDeletePushTokenOnSendError = true
ConfigDeletePushTokenOnSendError sets if tokens that have error on send are deleted from the database.
const CronContextName = "CRON"
CronContextName holds the cron service in gin context objects
const EnablePushMessaging = true
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 DbDeleteMessageId ¶
func DbGetCronboxByJobID ¶
func DbGetCronboxesForAll ¶
func DbGetCronboxesForOwner ¶
func DbGetJobTemplate ¶
func DbGetMessageByID ¶
func IsRunnable ¶
func SecureRandomAlphaString ¶
TODO: Duplicated from helper.go
func SecureRandomBytes ¶
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 models.JobID) (bool, error)
DeleteScheduledMessage stops a job (if running) and remove it from the db
func (*CronSender) GetCronboxes ¶
GetCronboxes returns all cronbox jobs for owner.
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 models.JobID) error
StartCronbox sets cronbox state to running
func (*CronSender) StopCronbox ¶
func (cs *CronSender) StopCronbox(JobID models.JobID, status int) error
StopCronbox sets cronbox state to stopped and remove from cron if running