This package has been based on the project https://github.com/robfig/cron
This package aims at implementing a distributed and fault tolerant cron in order to:
- Run an identical process on several hosts
- Each of these process instantiate a cron with the same rules
- Ensure only one of these processes executes an iteration of a job
By default the library creates an etcd client on 127.0.0.1:2379
c, _ := etcdcron.NewEtcdMutexBuilder(clientv3.Config{
Endpoints: []string{"etcd-host1:2379", "etcd-host2:2379"},
})
cron, _ := etcdcron.New(WithEtcdMutexBuilder(c))
cron.AddJob(Job{
Name: "job0",
Rhythm: "*/2 * * * * *",
Func: func(ctx context.Context) error {
// Handler
},
})
errorsHandler := func(ctx context.Context, job etcdcron.Job, err error) {
// Do something with the error which happened during 'job'
}
etcdErrorsHandler := func(ctx context.Context, job etcdcron.Job, err error) {
// Do something with the error which happened at the time of the execution of 'job'
// But locking mecanism fails because of etcd error
}
cron, _ := etcdcron.New(
WithErrorsHandler(errorsHandler),
WithEtcdErrorsHandler(etcdErrorsHandler),
)
cron.AddJob(Job{
Name: "job0",
Rhythm: "*/2 * * * * *",
Func: func(ctx context.Context) error {
// Handler
},
})
Bump new version number in CHANGELOG.md
and README.md
.
Commit, tag and create a new release:
version="1.3.3"
git switch --create release/${version}
git add CHANGELOG.md README.md
git commit --message="Bump v${version}"
git push --set-upstream origin release/${version}
gh pr create --reviewer=EtienneM --title "$(git log -1 --pretty=%B)"
Once the pull request merged, you can tag the new release.
git tag v${version}
git push origin master v${version}
gh release create v${version}
The title of the release should be the version number and the text of the release is the same as the changelog.