leader: Add a leader election package
Created by: ryanslade
This adds a small package to help with leader election around our Redis based mutex.
An example of how it could be used:
In repo-updater
, instead of:
go syncCloned(ctx, scheduler, gitserver.DefaultClient, store)
We would run:
go leader.Do(ctx, "repo-updater:syncCloned", func(ctx context.Context, release func()) {
defer release()
syncCloned(ctx, scheduler, gitserver.DefaultClient, store)
}, leader.Options{})