Commit 5824177f authored by Kyle Clarke's avatar Kyle Clarke 💬

Altered readme as it's bad practice to ignore errors and I don't in production...

Altered readme as it's bad practice to ignore errors and I don't in production code so this should be respected in read me files.
parent f1fa54d4
Pipeline #19818720 passed with stages
in 33 seconds
......@@ -25,26 +25,35 @@ First add the package with `go get gitlab.com/kylehqcom/kevin`
```
import(
"gitlab.com/kylehqcom/kevin"
"fmt"
"github.com/pkg/errors"
"gitlab.com/kylehqcom/kevin"
)
func Simple() {
// Do some repeated work.
}
JobID, _ := kevin.DefaultSchedule().Run(&Job{
JobID, err := kevin.DefaultSchedule().Run(&Job{
Fn: Simple,
Every: time.Duration(time.Second),
})
if err != nil {
return errors.Wrap(err, "run job failed")
}
// Some time later we check the status.
job, _ := kevin.DefaultSchedule().FindByJobID(JobID)
job, err := kevin.DefaultSchedule().FindByJobID(JobID)
if err != nil {
return errors.Wrap(err, "find job failed")
}
if job.IsRunning() {
// All is well
fmt.Println(fmt.Sprintf("Simple has run %d times.", job.RunningCount))
} else {
// Alert
// Alert, retry confirm?
}
// Since we haven't set an "Expires" value, let's stop manually.
......@@ -85,7 +94,7 @@ c := kevin.ScheduleConfig{
})
```
Of course you can always just call `purge()` manually on your schedule if you prefer.
Of course you can always just call `Purge()` manually on your schedule if you prefer.
```
// Purge all runners with a completed time older than one minute.
s.Purge(time.Duration(time.Minute))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment