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" "github.com/adamluzsi/frameless/adapters/memory" "github.com/adamluzsi/frameless/pkg/tasker/schedule" "log" "time" ) func main() { m := schedule.Scheduler{ LockerFactory: memory.NewLockerFactory[string](), Repository: memory.NewRepository[schedule.State, string](memory.NewMemory()), } job := m.WithSchedule("db maintenance", schedule.Interval(time.Hour*24*7), func(ctx context.Context) error { // this job is scheduled at every seven days return nil }) if err := job(context.Background()); err != nil { log.Println("ERROR", err.Error()) } }
Output:
type StateRepository ¶
Click to show internal directories.
Click to hide internal directories.