Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Scheduler ¶
type Scheduler struct { LockerFactory locks.Factory[string] Repository StateRepository }
func (Scheduler) WithSchedule ¶
func (s Scheduler) WithSchedule(jobid string, interval tasker.Interval, job tasker.Task) tasker.Task
Example ¶
package main import ( "context" "database/sql" "github.com/adamluzsi/frameless/pkg/logger" "github.com/adamluzsi/frameless/pkg/tasker/schedule" "log" "os" ) func main() { db, err := sql.Open("postgres", os.Getenv("DATABASE_URL")) if err != nil { logger.Fatal(nil, "error during postgres db opening", logger.ErrField(err)) os.Exit(1) } _ = db scheduler := schedule.Scheduler{ LockerFactory: nil, // &postgresql.LockerFactory[string]{DB: db}, Repository: nil, // &postgresql.TaskerScheduleStateRepository{DB: db}, } task := scheduler.WithSchedule("db maintenance", schedule.Monthly{Day: 1}, func(ctx context.Context) error { return nil }) if err := task(context.Background()); err != nil { log.Println("ERROR", err.Error()) } }
Output:
type StateRepository ¶
Click to show internal directories.
Click to hide internal directories.