Documentation
¶
Overview ¶
Package cron provides cron job scheduling using the robfig/cron library
Package cron provides service integration for cron scheduling
Index ¶
- type CleanupServiceInterface
- type Config
- type JobInfo
- type Scheduler
- func (s *Scheduler) AddJob(cronExpr string, jobName string, job func()) error
- func (s *Scheduler) AddPasswordResetCleanupJob(cronExpr string, cleanupService CleanupServiceInterface) error
- func (s *Scheduler) AddPasswordResetCleanupJobWithService(cronExpr string, cleanupService *reset.CleanupService) error
- func (s *Scheduler) GetEntries() []cron.Entry
- func (s *Scheduler) Start()
- func (s *Scheduler) Stop()
- type Service
- func (s *Service) AddCustomJob(cronExpr string, jobName string, job func()) error
- func (s *Service) GetJobEntries() []JobInfo
- func (s *Service) IsEnabled() bool
- func (s *Service) RunPasswordResetCleanupOnce(ctx context.Context, queries models.Querier) error
- func (s *Service) SetupPasswordResetCleanup(queries models.Querier, config ServiceConfig) error
- func (s *Service) Start() error
- func (s *Service) Stop()
- type ServiceConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CleanupServiceInterface ¶
CleanupServiceInterface defines the interface for cleanup services
type Config ¶
type Config struct {
// PasswordResetCleanupCron is the cron expression for password reset token cleanup
// Default: "*/5 * * * *" (every 5 minutes)
PasswordResetCleanupCron string
// TimeZone for cron jobs (default: UTC)
TimeZone string
}
Config holds configuration for the cron scheduler
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler manages cron jobs using the robfig/cron library
func NewScheduler ¶
NewScheduler creates a new cron scheduler
func (*Scheduler) AddPasswordResetCleanupJob ¶
func (s *Scheduler) AddPasswordResetCleanupJob(cronExpr string, cleanupService CleanupServiceInterface) error
AddPasswordResetCleanupJob adds a job to clean up expired password reset tokens
func (*Scheduler) AddPasswordResetCleanupJobWithService ¶
func (s *Scheduler) AddPasswordResetCleanupJobWithService(cronExpr string, cleanupService *reset.CleanupService) error
AddPasswordResetCleanupJobWithService is a convenience method that accepts *reset.CleanupService directly
func (*Scheduler) GetEntries ¶
func (s *Scheduler) GetEntries() []cron.Entry
GetEntries returns information about scheduled jobs
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages cron jobs for the application
func NewService ¶
func NewService(config ServiceConfig, logger *slog.Logger) (*Service, error)
NewService creates a new cron service
func (*Service) AddCustomJob ¶
AddCustomJob adds a custom cron job
func (*Service) GetJobEntries ¶
GetJobEntries returns information about scheduled jobs
func (*Service) RunPasswordResetCleanupOnce ¶
RunPasswordResetCleanupOnce runs the password reset cleanup job once (useful for testing)
func (*Service) SetupPasswordResetCleanup ¶
func (s *Service) SetupPasswordResetCleanup(queries models.Querier, config ServiceConfig) error
SetupPasswordResetCleanup configures password reset token cleanup job
type ServiceConfig ¶
type ServiceConfig struct {
// PasswordResetCleanupCron is the cron expression for password reset token cleanup
// Default: "*/5 * * * *" (every 5 minutes)
PasswordResetCleanupCron string
// TimeZone for cron jobs (default: UTC)
TimeZone string
// Enabled determines if cron jobs should run
Enabled bool
}
ServiceConfig holds configuration for the cron service
func LoadServiceConfigFromViper ¶
func LoadServiceConfigFromViper() ServiceConfig
LoadServiceConfigFromViper loads cron service configuration from viper