Skip to content

Commit

Permalink
feat: add Ensurer interface for leadership guarantees
Browse files Browse the repository at this point in the history
  • Loading branch information
manadart committed Dec 3, 2024
1 parent 9c45c18 commit 941c1e0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion core/leadership/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ type Token interface {
Check() error
}

// Checker exposes leadership testing capabilities.
// Checker exposes leadership checking capabilities.
type Checker interface {

// LeadershipCheck returns a Token representing the supplied unit's
Expand All @@ -117,6 +117,14 @@ type Checker interface {
LeadershipCheck(applicationId, unitId string) Token
}

// Ensurer describes the ability to guarantee leadership
// for the duration of some operation.
type Ensurer interface {
// WithLeader ensures that the input unit, holds leadership of the input
// application for the duration of execution of the input function.
WithLeader(ctx context.Context, appName, unitName string, fn func(context.Context) error) error
}

// Ticket is used to communicate leadership status to Tracker clients.
type Ticket interface {

Expand Down

0 comments on commit 941c1e0

Please sign in to comment.