Skip to content

Commit e586965

Browse files
committed
chore: coderabbit
1 parent 0da77e0 commit e586965

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

internal/leadership/broadcaster.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ type listener struct {
99
}
1010

1111
type Broadcaster struct {
12-
mu *sync.Mutex
12+
mu sync.Mutex
1313
t *Leadership
1414

1515
inner []listener
@@ -81,6 +81,5 @@ func (h *Broadcaster) CountListeners() int {
8181
func NewSignal() *Broadcaster {
8282
return &Broadcaster{
8383
outer: make(chan Leadership),
84-
mu: &sync.Mutex{},
8584
}
8685
}

internal/leadership/manager_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ func TestLeaderShip(t *testing.T) {
4343
}
4444
return false
4545
}, 2*time.Second, 10*time.Millisecond)
46+
leaderCount := 0
47+
for _, manager := range instances {
48+
if manager.GetSignal().Actual().Acquired {
49+
leaderCount++
50+
}
51+
}
52+
require.Equal(t, 1, leaderCount)
4653
require.GreaterOrEqual(t, selectedLeader, 0)
4754

4855
// ensure the provided db connection is still functionnal

0 commit comments

Comments
 (0)