# README
Go Etcd Cron v1.3.3
This package has been based on the project https://github.com/robfig/cron
Goal
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
Etcd Initialization
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
},
})
Error Handling
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
},
})
Release a New Version
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.
# Packages
No description provided by the author
# Functions
Every returns a crontab Schedule that activates once every duration.
New returns a new Cron job runner.
No description provided by the author
Parse returns a new crontab schedule representing the given spec.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
ConstantDelaySchedule represents a simple recurring duty cycle, e.g.
Cron keeps track of any number of entries, invoking the associated func as specified by the schedule.
Entry consists of a schedule and the func to execute on that schedule.
Job contains 3 mandatory options to define a job.
SpecSchedule specifies a duty cycle (to the second granularity), based on a traditional crontab specification.
# Interfaces
No description provided by the author
No description provided by the author
The Schedule describes a job's duty cycle.
# Type aliases
No description provided by the author