Skip to content

Commit

Permalink
Merge pull request #392 from pace/failover-context
Browse files Browse the repository at this point in the history
failover: Pass context to OnActive and OnPassive
  • Loading branch information
monstermunchkin authored Dec 20, 2024
2 parents e961281 + 1ec8a8e commit e3ebcdb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions maintenance/failover/failover.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ const Label = "github.com.pace.bricks.activepassive"
type ActivePassive struct {
// OnActive will be called in case the current processes
// is elected to be the active one
OnActive func()
OnActive func(ctx context.Context)

// OnPassive will be called in case the current process is
// the passive one
OnPassive func()
OnPassive func(ctx context.Context)

// OnStop is called after the ActivePassive process stops
OnStop func()
Expand Down Expand Up @@ -203,15 +203,15 @@ func (a *ActivePassive) label(s status) string {
func (a *ActivePassive) becomeActive(ctx context.Context) {
if a.setState(ctx, ACTIVE) {
if a.OnActive != nil {
a.OnActive()
a.OnActive(ctx)
}
}
}

func (a *ActivePassive) becomePassive(ctx context.Context) {
if a.setState(ctx, PASSIVE) {
if a.OnPassive != nil {
a.OnPassive()
a.OnPassive(ctx)
}
}
}
Expand Down

0 comments on commit e3ebcdb

Please sign in to comment.