scheduler

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package scheduler provides task scheduling and job management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultJobs

func DefaultJobs() []*models.ScheduledJob

DefaultJobs returns a cloned copy of the built-in scheduled jobs.

Types

type Handler

type Handler func(context.Context, *models.ScheduledJob) error

Handler executes a scheduled job.

type Option

type Option func(*options)

Option applies configuration to the scheduler service.

func WithCache

func WithCache(c *cache.RedisCache) Option

WithCache injects the Redis/Valkey cache client used for status persistence.

func WithConnectorFactory

func WithConnectorFactory(factory connector.Factory) Option

WithConnectorFactory overrides the inbound connector factory.

func WithCron

func WithCron(c *cron.Cron) Option

WithCron supplies a preconfigured cron scheduler instance.

func WithCronParser

func WithCronParser(p cron.Parser) Option

WithCronParser allows replacing the cron expression parser.

func WithEmailAccountLister

func WithEmailAccountLister(repo emailAccountLister) Option

WithEmailAccountLister injects the repository used for email polling.

func WithEmailHandler

func WithEmailHandler(handler connector.Handler) Option

WithEmailHandler injects the connector.Handler used to process inbound messages.

func WithJobs

func WithJobs(jobs []*models.ScheduledJob) Option

WithJobs registers explicit job definitions instead of defaults.

func WithLocation

func WithLocation(loc *time.Location) Option

WithLocation sets the scheduler timezone location.

func WithLogger

func WithLogger(l *log.Logger) Option

WithLogger injects a custom logger implementation.

func WithReminderHub

func WithReminderHub(h notifications.Hub) Option

WithReminderHub injects a custom reminder hub for dispatching pending reminders.

func WithTicketAutoCloser

func WithTicketAutoCloser(repo ticketAutoCloser) Option

WithTicketAutoCloser injects a custom ticket auto-close repository.

type Service

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

Service coordinates scheduled job execution.

func NewService

func NewService(db *sql.DB, opts ...Option) *Service

NewService wires a scheduler around the shared database connection.

func (*Service) AddJob

func (s *Service) AddJob(job *models.ScheduledJob) error

AddJob dynamically adds a job to the scheduler. The job's Handler field should match a registered handler name. Can be called after the scheduler has started.

func (*Service) RegisterHandler

func (s *Service) RegisterHandler(name string, handler Handler)

RegisterHandler attaches or replaces a handler for the given name. Passing nil removes the handler.

func (*Service) Run

func (s *Service) Run(ctx context.Context) error

Run starts the scheduler loop until the context is cancelled.

Jump to

Keyboard shortcuts

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