Documentation
¶
Index ¶
- Variables
- func InitializeCronJobSchedulerContainer(ctx core.Context, config *settings.Config, startScheduler bool) error
- func NewGocronLoggerAdapter() gocron.Logger
- type CronJob
- type CronJobEvery15MinutesPeriod
- type CronJobFixedHourPeriod
- type CronJobFixedTimePeriod
- type CronJobIntervalPeriod
- type CronJobPeriod
- type CronJobSchedulerContainer
- type GocronLoggerAdapter
Constants ¶
This section is empty.
Variables ¶
var ( Container = &CronJobSchedulerContainer{ allJobsMap: make(map[string]*CronJob), allGocronJobsMap: make(map[string]gocron.Job), } )
Initialize a cron job scheduler container singleton instance
var CreateScheduledTransactionJob = &CronJob{ Name: "CreateScheduledTransaction", Description: "Periodically create transaction by scheduled transaction template.", Period: CronJobEvery15MinutesPeriod{ Second: 0, }, Run: func(c *core.CronContext) error { return services.Transactions.CreateScheduledTransactions(c, time.Now().Unix(), c.GetInterval()) }, }
CreateScheduledTransactionJob represents the cron job which periodically create transaction by scheduled transaction template
var RemoveExpiredTokensJob = &CronJob{ Name: "RemoveExpiredTokens", Description: "Periodically remove expired user tokens from the database.", Period: CronJobFixedHourPeriod{ Hour: 0, }, Run: func(c *core.CronContext) error { return services.Tokens.DeleteAllExpiredTokens(c) }, }
RemoveExpiredTokensJob represents the cron job which periodically remove expired user tokens from the database
Functions ¶
func InitializeCronJobSchedulerContainer ¶
func InitializeCronJobSchedulerContainer(ctx core.Context, config *settings.Config, startScheduler bool) error
InitializeCronJobSchedulerContainer initializes the cron job scheduler according to the config
func NewGocronLoggerAdapter ¶
NewGocronLoggerAdapter returns a new GocronLoggerAdapter instance
Types ¶
type CronJob ¶
type CronJob struct {
Name string
Description string
Period CronJobPeriod
Run func(*core.CronContext) error
}
CronJob represents the cron job instance
type CronJobEvery15MinutesPeriod ¶
type CronJobEvery15MinutesPeriod struct {
Second uint32
}
CronJobEvery15MinutesPeriod represents the period of execution at every 15 minutes
func (CronJobEvery15MinutesPeriod) GetInterval ¶
func (p CronJobEvery15MinutesPeriod) GetInterval() time.Duration
GetInterval returns the interval time of the period of CronJobEvery15MinutesPeriod
func (CronJobEvery15MinutesPeriod) ToJobDefinition ¶
func (p CronJobEvery15MinutesPeriod) ToJobDefinition() gocron.JobDefinition
ToJobDefinition returns the gocron job definition of the period of CronJobEvery15MinutesPeriod
type CronJobFixedHourPeriod ¶
type CronJobFixedHourPeriod struct {
Hour uint32
}
CronJobFixedHourPeriod represents the period of execution at fixed hour
func (CronJobFixedHourPeriod) GetInterval ¶
func (p CronJobFixedHourPeriod) GetInterval() time.Duration
GetInterval returns the interval time of the period of CronJobFixedHourPeriod
func (CronJobFixedHourPeriod) ToJobDefinition ¶
func (p CronJobFixedHourPeriod) ToJobDefinition() gocron.JobDefinition
ToJobDefinition returns the gocron job definition of the period of CronJobFixedHourPeriod
type CronJobFixedTimePeriod ¶
CronJobFixedTimePeriod represents the period of execution at fixed time
func (CronJobFixedTimePeriod) GetInterval ¶
func (p CronJobFixedTimePeriod) GetInterval() time.Duration
GetInterval returns the interval time of the period of CronJobFixedTimePeriod
func (CronJobFixedTimePeriod) ToJobDefinition ¶
func (p CronJobFixedTimePeriod) ToJobDefinition() gocron.JobDefinition
ToJobDefinition returns the gocron job definition of the period of CronJobFixedTimePeriod
type CronJobIntervalPeriod ¶
CronJobIntervalPeriod represents the period of execution at intervals
func (CronJobIntervalPeriod) GetInterval ¶
func (p CronJobIntervalPeriod) GetInterval() time.Duration
GetInterval returns the interval time of the period of CronJobIntervalPeriod
func (CronJobIntervalPeriod) ToJobDefinition ¶
func (p CronJobIntervalPeriod) ToJobDefinition() gocron.JobDefinition
ToJobDefinition returns the gocron job definition of the period of CronJobIntervalPeriod
type CronJobPeriod ¶
type CronJobPeriod interface {
GetInterval() time.Duration
ToJobDefinition() gocron.JobDefinition
}
CronJobPeriod represents the cron job period
type CronJobSchedulerContainer ¶
type CronJobSchedulerContainer struct {
// contains filtered or unexported fields
}
CronJobSchedulerContainer contains the current cron job scheduler
func (*CronJobSchedulerContainer) GetAllJobs ¶
func (c *CronJobSchedulerContainer) GetAllJobs() []*CronJob
GetAllJobs returns all the cron jobs
func (*CronJobSchedulerContainer) SyncRunJobNow ¶
func (c *CronJobSchedulerContainer) SyncRunJobNow(jobName string) error
SyncRunJobNow runs the specified cron job synchronously now
type GocronLoggerAdapter ¶
type GocronLoggerAdapter struct {
}
GocronLoggerAdapter represents the logger adapter for gocron
func (GocronLoggerAdapter) Debug ¶
func (logger GocronLoggerAdapter) Debug(msg string, args ...any)
Debug logs debug log
func (GocronLoggerAdapter) Error ¶
func (logger GocronLoggerAdapter) Error(msg string, args ...any)
Error logs error log
func (GocronLoggerAdapter) Info ¶
func (logger GocronLoggerAdapter) Info(msg string, args ...any)
Info logs info log
func (GocronLoggerAdapter) Warn ¶
func (logger GocronLoggerAdapter) Warn(msg string, args ...any)
Warn logs warn log