style: fix golangci-lint formatting issues
- Run gofmt on all swarm package files - Fix unnecessary int64 conversion in metrics.go - Break long line in leader_election.go for golines Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
050f99ef0c
commit
d17bc02493
11 changed files with 156 additions and 155 deletions
|
|
@ -178,7 +178,8 @@ func (le *LeaderElection) monitorLeader() {
|
||||||
|
|
||||||
// Check if leader is still in the membership
|
// Check if leader is still in the membership
|
||||||
if _, exists := le.membership.GetNode(leaderID); !exists {
|
if _, exists := le.membership.GetNode(leaderID); !exists {
|
||||||
logger.WarnCF("swarm", "Leader no longer in membership, triggering reelection", map[string]any{"leader_id": leaderID})
|
logger.WarnCF("swarm", "Leader no longer in membership, triggering reelection",
|
||||||
|
map[string]any{"leader_id": leaderID})
|
||||||
// Trigger reelection by clearing current leader
|
// Trigger reelection by clearing current leader
|
||||||
le.mu.Lock()
|
le.mu.Lock()
|
||||||
le.currentLeader = ""
|
le.currentLeader = ""
|
||||||
|
|
|
||||||
|
|
@ -245,7 +245,7 @@ func (lm *LoadMonitor) GetTrend() string {
|
||||||
|
|
||||||
// Simple linear regression to detect trend
|
// Simple linear regression to detect trend
|
||||||
n := float64(len(lm.samples))
|
n := float64(len(lm.samples))
|
||||||
sumX := n*(n-1)/2
|
sumX := n * (n - 1) / 2
|
||||||
sumY := 0.0
|
sumY := 0.0
|
||||||
sumXY := 0.0
|
sumXY := 0.0
|
||||||
|
|
||||||
|
|
@ -255,7 +255,7 @@ func (lm *LoadMonitor) GetTrend() string {
|
||||||
sumXY += x * s
|
sumXY += x * s
|
||||||
}
|
}
|
||||||
|
|
||||||
slope := (n*sumXY - sumX*sumY) / (n*(n-1)*(2*n-1)/6)
|
slope := (n*sumXY - sumX*sumY) / (n * (n - 1) * (2*n - 1) / 6)
|
||||||
|
|
||||||
if slope > TrendIncreasingThreshold {
|
if slope > TrendIncreasingThreshold {
|
||||||
return "increasing"
|
return "increasing"
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ func (m *MetricsCollector) RecordLatency(operation string, latency time.Duration
|
||||||
bucket := m.latencyBuckets[operation]
|
bucket := m.latencyBuckets[operation]
|
||||||
m.mu.Unlock()
|
m.mu.Unlock()
|
||||||
|
|
||||||
ms := int64(latency.Milliseconds())
|
ms := latency.Milliseconds()
|
||||||
|
|
||||||
bucket.mu.Lock()
|
bucket.mu.Lock()
|
||||||
bucket.count++
|
bucket.count++
|
||||||
|
|
@ -205,7 +205,7 @@ func (m *MetricsCollector) percentile(bucket *LatencyBucket, p float64) float64
|
||||||
cumulative := int64(0)
|
cumulative := int64(0)
|
||||||
|
|
||||||
// Upper bounds for each bucket in ms
|
// Upper bounds for each bucket in ms
|
||||||
upperBounds := []int64{1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 1<<62}
|
upperBounds := []int64{1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 1 << 62}
|
||||||
|
|
||||||
for i, count := range bucket.buckets {
|
for i, count := range bucket.buckets {
|
||||||
cumulative += count
|
cumulative += count
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue