Skip to content

Commit

Permalink
Changes as per PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
prudhvi committed Dec 20, 2023
1 parent f490324 commit 64f3b97
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 54 deletions.
51 changes: 0 additions & 51 deletions ha/factory.go

This file was deleted.

33 changes: 31 additions & 2 deletions ha/ha.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,45 @@

package ha

import (
"sync"

"github.com/cashapp/blip"
)

type Manager interface {
Standby() bool
}

type disabled struct{}
type ManagerFactory interface {
Make(monitor blip.ConfigMonitor) (Manager, error)
}

var _ Manager = disabled{}
type disabled struct {
mf ManagerFactory
}

func (d disabled) Standby() bool {
return false
}

var once sync.Once
var Disabled = disabled{}

// Internal factory disabled by default (HA not used).
var f ManagerFactory = Disabled

func Register(mf ManagerFactory) {
once.Do(func() {
f = mf
blip.Debug("register HA")
})
}

func Make(args blip.ConfigMonitor) (Manager, error) {
return f.Make(args)
}

func (f disabled) Make(_ blip.ConfigMonitor) (Manager, error) {
return Disabled, nil
}
2 changes: 1 addition & 1 deletion monitor/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"crypto/sha256"
"errors"
"fmt"
"github.com/cashapp/blip/ha"
"os"
"sync"
"time"
Expand All @@ -18,6 +17,7 @@ import (
"github.com/cashapp/blip/aws"
"github.com/cashapp/blip/dbconn"
"github.com/cashapp/blip/event"
"github.com/cashapp/blip/ha"
"github.com/cashapp/blip/plan"
"github.com/cashapp/blip/sink"
"github.com/cashapp/blip/status"
Expand Down

0 comments on commit 64f3b97

Please sign in to comment.