Skip to content

Commit e3ebcdb

Browse files
Merge pull request #392 from pace/failover-context
failover: Pass context to OnActive and OnPassive
2 parents e961281 + 1ec8a8e commit e3ebcdb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

maintenance/failover/failover.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ const Label = "github.com.pace.bricks.activepassive"
4141
type ActivePassive struct {
4242
// OnActive will be called in case the current processes
4343
// is elected to be the active one
44-
OnActive func()
44+
OnActive func(ctx context.Context)
4545

4646
// OnPassive will be called in case the current process is
4747
// the passive one
48-
OnPassive func()
48+
OnPassive func(ctx context.Context)
4949

5050
// OnStop is called after the ActivePassive process stops
5151
OnStop func()
@@ -203,15 +203,15 @@ func (a *ActivePassive) label(s status) string {
203203
func (a *ActivePassive) becomeActive(ctx context.Context) {
204204
if a.setState(ctx, ACTIVE) {
205205
if a.OnActive != nil {
206-
a.OnActive()
206+
a.OnActive(ctx)
207207
}
208208
}
209209
}
210210

211211
func (a *ActivePassive) becomePassive(ctx context.Context) {
212212
if a.setState(ctx, PASSIVE) {
213213
if a.OnPassive != nil {
214-
a.OnPassive()
214+
a.OnPassive(ctx)
215215
}
216216
}
217217
}

0 commit comments

Comments
 (0)