Skip to content

Commit

Permalink
style: reduce warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
qazwsxedckll committed Mar 21, 2024
1 parent 225f8e7 commit 70165d4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
2 changes: 0 additions & 2 deletions cluster/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ func withClusterReceiveMiddleware() actor.PropsOption {
default:
next(c, envelope)
}

return
}
})
}
Expand Down
15 changes: 6 additions & 9 deletions cluster/consensus_check_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package cluster

import (
"context"
"fmt"
"log/slog"
"strings"
Expand Down Expand Up @@ -132,23 +133,19 @@ func (ccb *ConsensusCheckBuilder) build() func(*GossipState, map[string]empty) (
}

showLog := func(hasConsensus bool, topologyHash uint64, valueTuples []*consensusMemberValue) {
if ccb.logger.Enabled(nil, slog.LevelDebug) {
if ccb.logger.Enabled(context.Background(), slog.LevelDebug) {
groups := map[string]int{}
for _, memberValue := range valueTuples {
key := fmt.Sprintf("%s:%d", memberValue.key, memberValue.value)
if _, ok := groups[key]; ok {
groups[key]++
} else {
groups[key] = 1
}
groups[key]++
}

for k, value := range groups {
suffix := strings.Split(k, ":")[0]
if value > 1 {
suffix = fmt.Sprintf("%s, %d nodes", k, value)
}
ccb.logger.Debug("consensus", slog.Bool("consensus", hasConsensus), slog.String("values", suffix))
ccb.logger.Debug("consensus", slog.Bool("consensus", hasConsensus), slog.String("values", suffix), slog.Uint64("topologyHash", topologyHash))
}
}
}
Expand All @@ -157,7 +154,7 @@ func (ccb *ConsensusCheckBuilder) build() func(*GossipState, map[string]empty) (
mapToValue := ccb.MapToValue(ccb.getConsensusValues[0])

return func(state *GossipState, ids map[string]empty) (bool, interface{}) {
var memberStates []map[string]*GossipMemberState
memberStates := []map[string]*GossipMemberState{}
getValidMemberStates(state, ids, memberStates)

if len(memberStates) < len(ids) { // Not all members have state...
Expand All @@ -180,7 +177,7 @@ func (ccb *ConsensusCheckBuilder) build() func(*GossipState, map[string]empty) (
}

return func(state *GossipState, ids map[string]empty) (bool, interface{}) {
var memberStates []map[string]*GossipMemberState
memberStates := []map[string]*GossipMemberState{}
getValidMemberStates(state, ids, memberStates)

if len(memberStates) < len(ids) { // Not all members have state...
Expand Down
2 changes: 0 additions & 2 deletions cluster/gossip_actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type GossipActor struct {

// Creates a new GossipActor and returns a pointer to its location in the heap
func NewGossipActor(requestTimeout time.Duration, myID string, getBlockedMembers func() set.Set[string], fanOut int, maxSend int, system *actor.ActorSystem) *GossipActor {

logger := system.Logger()
informer := newInformer(myID, getBlockedMembers, fanOut, maxSend, logger)
gossipActor := GossipActor{
Expand Down Expand Up @@ -111,7 +110,6 @@ func (ga *GossipActor) onGossipRequest(r *GossipRequest, ctx actor.Context) {
}

ctx.Respond(&GossipResponse{})
return

// turn off acking for now

Expand Down
2 changes: 1 addition & 1 deletion cluster/gossiper.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func (g *Gossiper) blockExpiredHeartbeats() {
for k, v := range t {
if k != g.cluster.ActorSystem.ID &&
!blockList.IsBlocked(k) &&
time.Now().Sub(time.UnixMilli(v.LocalTimestampUnixMilliseconds)) > g.cluster.Config.HeartbeatExpiration {
time.Since(time.UnixMilli(v.LocalTimestampUnixMilliseconds)) > g.cluster.Config.HeartbeatExpiration {
blocked = append(blocked, k)
}
}
Expand Down

0 comments on commit 70165d4

Please sign in to comment.