fix go.mod + doc

This commit is contained in:
rmanach 2024-11-16 11:15:30 +01:00
parent 2a0ecf2d4e
commit 4a39ba5547
3 changed files with 11 additions and 7 deletions

View File

@ -1,6 +1,6 @@
# 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.
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.
**NOTE**: this should be not used for long-running tasks, it's more suitable for shorts tasks like polling etc...
@ -9,18 +9,22 @@ cycle-scheduler is a simple scheduler lib, handling tasks and executes them at r
```go
import (
"context"
scheduler "gitea.thegux.fr/rmanach/cycle-scheduler.git"
)
ctx := context.Background()
s := NewSchedulerCycle(ctx, 4)
s := scheduler.NewSchedulerCycle(ctx, 4)
// add a task
// add a task with an execution interval of 2 ms (executed every 2 ms)
// and a maximum duration of 30 second.
taskID := s.Delay(
func(ctx context.Context) (any, error) {
// execution
// ...
return any, nil
},
WithExecInterval(2*time.Millisecond)
scheduler.WithExecInterval(2*time.Millisecond),
scheduler.WithMaxDuration(30*time.Second)
)
<-ctx.Done()

2
go.mod
View File

@ -1,4 +1,4 @@
module cycle-scheduler
module gitea.thegux.fr/rmanach/cycle-scheduler.git
go 1.22.4

View File

@ -20,7 +20,7 @@ type IScheduler interface {
}
// SchedulerCycle is a simple scheduler handling jobs and executes them at regular interval.
// If a task is not in desired state, the task is re-scheduled with a backoff.
// If a task is not in desired state, the task is re-scheduled.
type SchedulerCycle struct {
wg sync.WaitGroup