refactor: extract magic numbers to named constants
Replace inline numeric literals with named constants across 14 files: server timeouts/rate limits, cluster thresholds/intervals, DB pool sizes, alert/dial timeouts, TUI uptime thresholds, node status thresholds, and state history limits.
This commit was merged in pull request #153.
This commit is contained in:
@@ -38,14 +38,20 @@ func Start(ctx context.Context, cfg Config, eng *monitor.Engine) {
|
||||
// "probe" mode is handled directly in main.go before cluster.Start is called
|
||||
}
|
||||
|
||||
const (
|
||||
followerTimeout = 2 * time.Second
|
||||
leaderFailureThreshold = 3
|
||||
followerRetryInterval = 5 * time.Second
|
||||
)
|
||||
|
||||
func runFollowerLoop(ctx context.Context, cfg Config, eng *monitor.Engine) {
|
||||
client := http.Client{Timeout: 2 * time.Second}
|
||||
client := http.Client{Timeout: followerTimeout}
|
||||
failures := 0
|
||||
threshold := 3
|
||||
threshold := leaderFailureThreshold
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-time.After(5 * time.Second):
|
||||
case <-time.After(followerRetryInterval):
|
||||
case <-ctx.Done():
|
||||
return
|
||||
}
|
||||
@@ -59,7 +65,7 @@ func runFollowerLoop(ctx context.Context, cfg Config, eng *monitor.Engine) {
|
||||
isLeaderHealthy := false
|
||||
|
||||
if err == nil {
|
||||
isLeaderHealthy = resp.StatusCode == 200
|
||||
isLeaderHealthy = resp.StatusCode == http.StatusOK
|
||||
_ = resp.Body.Close()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user