Skip to content

leader: Add a leader election package

Administrator requested to merge leader-election into master

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{})

Merge request reports

Loading