update:To standardize the time format, use the go standard library's own (#4875)

This commit is contained in:
me-cs
2025-05-22 23:26:53 +08:00
committed by GitHub
parent b109b3ef4c
commit e7bd0d8b60
5 changed files with 13 additions and 16 deletions

View File

@@ -15,7 +15,6 @@ import (
const (
numHistoryReasons = 5
timeFormat = "15:04:05"
)
// ErrServiceUnavailable is returned when the Breaker state is open.
@@ -261,7 +260,7 @@ type errorWindow struct {
func (ew *errorWindow) add(reason string) {
ew.lock.Lock()
ew.reasons[ew.index] = fmt.Sprintf("%s %s", time.Now().Format(timeFormat), reason)
ew.reasons[ew.index] = fmt.Sprintf("%s %s", time.Now().Format(time.TimeOnly), reason)
ew.index = (ew.index + 1) % numHistoryReasons
ew.count = min(ew.count+1, numHistoryReasons)
ew.lock.Unlock()