From 1ec8a8e841822bac6bf6e645cd2c1b90424a8333 Mon Sep 17 00:00:00 2001 From: Thomas Hipp Date: Tue, 17 Dec 2024 14:52:16 +0100 Subject: [PATCH] failover: Pass context to OnActive and OnPassive --- maintenance/failover/failover.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/maintenance/failover/failover.go b/maintenance/failover/failover.go index 36d41c7c6..5ce21712c 100644 --- a/maintenance/failover/failover.go +++ b/maintenance/failover/failover.go @@ -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() @@ -203,7 +203,7 @@ 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) } } } @@ -211,7 +211,7 @@ func (a *ActivePassive) becomeActive(ctx context.Context) { func (a *ActivePassive) becomePassive(ctx context.Context) { if a.setState(ctx, PASSIVE) { if a.OnPassive != nil { - a.OnPassive() + a.OnPassive(ctx) } } }