Skip to content

Commit

Permalink
Make HAManager configurable by Blip users
Browse files Browse the repository at this point in the history
  • Loading branch information
prudhvi committed Dec 18, 2023
1 parent 6d6adfc commit 451fe70
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions ha/ha.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

package ha

import "sync"

type Manager interface {
Standby() bool
}
Expand All @@ -15,3 +17,12 @@ func (d disabled) Standby() bool {
}

var Disabled = disabled{}

// HAManagerImpl is the Manager implementation that monitor uses.
// Defaults to Disabled, SetHAManager (before Server.Run) to override.
var HAManagerImpl Manager = Disabled
var once sync.Once

func SetHAManager(m Manager) {
once.Do(func() { HAManagerImpl = m })
}
2 changes: 1 addition & 1 deletion monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ func (m *Monitor) startup() error {
Config: m.cfg.Plans.Change,
DB: m.db,
LCO: m.lco,
HA: ha.Disabled,
HA: ha.HAManagerImpl,
})

m.wg.Add(1)
Expand Down

0 comments on commit 451fe70

Please sign in to comment.