cycle-scheduler
cycle-scheduler is a simple scheduler lib, handling tasks and executes them at regular interval. If a task is not in desired state, the task is re-scheduled with a backoff.
NOTE: this should be not used for long-running tasks, it's more suitable for shorts tasks like polling etc...
Examples
- Init a new scheduler with 4 workers
import (
"context"
)
ctx := context.Background()
s := NewSchedulerCycle(ctx, 4)
// add a task
taskID := s.Delay(
func(ctx context.Context) (any, error) {
// execution
return any, nil
},
WithExecInterval(2*time.Millisecond)
)
<-ctx.Done()
<-s.Done()
NOTE: for Delay optionals arguments, check the NewTask method documentation for more details.
Description
cycle-scheduler is a simple scheduler handling jobs and executes them at regular interval.
Languages
Go
99.7%
Makefile
0.3%