Forráskód Böngészése

chore: refactoring (#2182)

Kevin Wan 2 éve
szülő
commit
92145b56dc

+ 10 - 10
core/logx/rotatelogger.go

@@ -19,14 +19,14 @@ import (
 )
 
 const (
-	rfc3339DateFormat = time.RFC3339
-	dateFormat        = "2006-01-02"
-	hoursPerDay       = 24
-	bufferSize        = 100
-	defaultDirMode    = 0o755
-	defaultFileMode   = 0o600
-	gzipExt           = ".gz"
-	megaBytes         = 1 << 20
+	dateFormat      = "2006-01-02"
+	fileTimeFormat  = time.RFC3339
+	hoursPerDay     = 24
+	bufferSize      = 100
+	defaultDirMode  = 0o755
+	defaultFileMode = 0o600
+	gzipExt         = ".gz"
+	megaBytes       = 1 << 20
 )
 
 // ErrLogFileClosed is an error that indicates the log file is already closed.
@@ -195,7 +195,7 @@ func (r *SizeLimitRotateRule) OutdatedFiles() []string {
 
 	// test if any too old backups
 	if r.days > 0 {
-		boundary := time.Now().Add(-time.Hour * time.Duration(hoursPerDay*r.days)).Format(rfc3339DateFormat)
+		boundary := time.Now().Add(-time.Hour * time.Duration(hoursPerDay*r.days)).Format(fileTimeFormat)
 		boundaryFile := filepath.Join(dir, fmt.Sprintf("%s%s%s%s", prefix, r.delimiter, boundary, ext))
 		if r.gzip {
 			boundaryFile += gzipExt
@@ -413,7 +413,7 @@ func getNowDate() string {
 }
 
 func getNowDateInRFC3339Format() string {
-	return time.Now().Format(rfc3339DateFormat)
+	return time.Now().Format(fileTimeFormat)
 }
 
 func gzipFile(file string) error {

+ 1 - 1
core/logx/rotatelogger_test.go

@@ -51,7 +51,7 @@ func TestSizeLimitRotateRuleOutdatedFiles(t *testing.T) {
 
 func TestSizeLimitRotateRuleShallRotate(t *testing.T) {
 	var rule SizeLimitRotateRule
-	rule.rotatedTime = time.Now().Add(time.Hour * 24).Format(rfc3339DateFormat)
+	rule.rotatedTime = time.Now().Add(time.Hour * 24).Format(fileTimeFormat)
 	rule.maxSize = 0
 	assert.False(t, rule.ShallRotate(0))
 	rule.maxSize = 100

+ 3 - 3
zrpc/internal/rpcpubserver.go

@@ -41,12 +41,12 @@ type keepAliveServer struct {
 	Server
 }
 
-func (ags keepAliveServer) Start(fn RegisterFn) error {
-	if err := ags.registerEtcd(); err != nil {
+func (s keepAliveServer) Start(fn RegisterFn) error {
+	if err := s.registerEtcd(); err != nil {
 		return err
 	}
 
-	return ags.Server.Start(fn)
+	return s.Server.Start(fn)
 }
 
 func figureOutListenOn(listenOn string) string {