humingcheng commented on code in PR #1494:
URL: 
https://github.com/apache/servicecomb-service-center/pull/1494#discussion_r1865352702


##########
pkg/rest/first_launch.go:
##########
@@ -0,0 +1,71 @@
+package rest
+
+import (
+       "errors"
+       "io/fs"
+       "os"
+       "path/filepath"
+       "time"
+
+       "github.com/apache/servicecomb-service-center/server/config"
+
+       "github.com/apache/servicecomb-service-center/pkg/log"
+)
+
+/**
+for restart service center, set a 2-minute time window to return http status 
304 on discovery apis,
+indicating that sdk not need to clear cache
+*/
+
+var (
+       isWithinProtection        bool
+       startupTimestamp          int64
+       firstLaunchFlagPath       string
+       enableInstanceNullProtect bool
+       restartProtectInterval    time.Duration
+       RestartProtectHttpCode    int
+)
+
+func Init() {
+       enableInstanceNullProtect = 
config.GetBool("instance_null_protect.enable", true)

Review Comment:
   默认是关,因为这个功能会影响调试,可能造成开源开发者的困扰。



##########
pkg/rest/first_launch.go:
##########
@@ -0,0 +1,71 @@
+package rest
+
+import (
+       "errors"
+       "io/fs"
+       "os"
+       "path/filepath"
+       "time"
+
+       "github.com/apache/servicecomb-service-center/server/config"
+
+       "github.com/apache/servicecomb-service-center/pkg/log"
+)
+
+/**
+for restart service center, set a 2-minute time window to return http status 
304 on discovery apis,
+indicating that sdk not need to clear cache
+*/
+
+var (
+       isWithinProtection        bool
+       startupTimestamp          int64
+       firstLaunchFlagPath       string
+       enableInstanceNullProtect bool
+       restartProtectInterval    time.Duration
+       RestartProtectHttpCode    int
+)
+
+func Init() {
+       enableInstanceNullProtect = 
config.GetBool("instance_null_protect.enable", true)
+       restartProtectInterval = 
time.Duration(config.GetInt("instance_null_protect.restart_protect_interval", 
120)) * time.Second

Review Comment:
   输入参数校验,有效值1-120秒,默认120秒,如果参数非法则打日志提示,并设置为120秒。



##########
pkg/rest/first_launch.go:
##########
@@ -0,0 +1,71 @@
+package rest
+
+import (
+       "errors"
+       "io/fs"
+       "os"
+       "path/filepath"
+       "time"
+
+       "github.com/apache/servicecomb-service-center/server/config"
+
+       "github.com/apache/servicecomb-service-center/pkg/log"
+)
+
+/**
+for restart service center, set a 2-minute time window to return http status 
304 on discovery apis,
+indicating that sdk not need to clear cache
+*/
+
+var (
+       isWithinProtection        bool
+       startupTimestamp          int64
+       firstLaunchFlagPath       string
+       enableInstanceNullProtect bool
+       restartProtectInterval    time.Duration
+       RestartProtectHttpCode    int
+)
+
+func Init() {
+       enableInstanceNullProtect = 
config.GetBool("instance_null_protect.enable", true)
+       restartProtectInterval = 
time.Duration(config.GetInt("instance_null_protect.restart_protect_interval", 
120)) * time.Second
+       RestartProtectHttpCode = 
config.GetInt("instance_null_protect.http_status", 304)
+       logDir := filepath.Dir(config.GetString("log.file", "", 
config.WithStandby("logfile")))
+       firstLaunchFlagPath = filepath.Join(logDir, "first_launch.flag")

Review Comment:
   日志打印关键参数



##########
pkg/rest/first_launch.go:
##########
@@ -0,0 +1,71 @@
+package rest
+
+import (
+       "errors"
+       "io/fs"
+       "os"
+       "path/filepath"
+       "time"
+
+       "github.com/apache/servicecomb-service-center/server/config"
+
+       "github.com/apache/servicecomb-service-center/pkg/log"
+)
+
+/**
+for restart service center, set a 2-minute time window to return http status 
304 on discovery apis,

Review Comment:
   注释错误,不要固化参数值



##########
server/resource/disco/instance_resource.go:
##########
@@ -167,6 +168,10 @@ func (s *InstanceResource) FindInstances(w 
http.ResponseWriter, r *http.Request)
                w.WriteHeader(http.StatusNotModified)
                return
        }
+       if len(resp.Instances) == 0 && rest.IsWithinRestartProtection() {

Review Comment:
   保护逻辑,放在service/disco目录下



-- 
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]

Reply via email to