humingcheng commented on code in PR #1494:
URL:
https://github.com/apache/servicecomb-service-center/pull/1494#discussion_r1865526918
##########
pkg/protect/protect.go:
##########
@@ -0,0 +1,71 @@
+package protect
+
+import (
+ "fmt"
+ "github.com/apache/servicecomb-service-center/pkg/util"
+ "net/http"
+ "time"
+
+ "github.com/apache/servicecomb-service-center/server/config"
+
+ "github.com/apache/servicecomb-service-center/pkg/log"
+)
+
+/**
+for restart service center, set a restartProtectInterval time window to return
RestartProtectHttpCode on discovery apis,
+indicating that sdk not need to clear cache
+*/
+
+var (
+ isWithinProtection bool
+ startupTimestamp int64
+ enableInstanceNullProtect bool
+ restartProtectInterval time.Duration
+ RestartProtectHttpCode int
+ validProtectCode = []int{http.StatusNotModified,
http.StatusUnprocessableEntity, http.StatusInternalServerError}
+)
+
+const (
+ maxInterval = 120 * time.Second
+ minInterval = 0 * time.Second
+ defaultRestartProtectInterval = 120 * time.Second
+)
+
+func Init() {
+ enableInstanceNullProtect =
config.GetBool("instance_null_protect.enable", false)
+ restartProtectInterval =
time.Duration(config.GetInt("instance_null_protect.restart_protect_interval",
120)) * time.Second
Review Comment:
enable为false的时候,直接退出,不用做初始化的操作了
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]