You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/07/02 09:57:27 UTC

[GitHub] [servicecomb-service-center] tianxiaoliang opened a new pull request #660: add more action for code quality (#657)

tianxiaoliang opened a new pull request #660:
URL: https://github.com/apache/servicecomb-service-center/pull/660


   Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it).  Trivial changes like typos do not require a JIRA issue.  Your pull request should address just this issue, without pulling in other changes.
    - [ ] Each commit in the pull request should have a meaningful subject line and body.
    - [ ] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue.
    - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
    - [ ] Run `go build` `go test` `go fmt` `go vet` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   ---
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-service-center] humingcheng commented on a change in pull request #660: add more action for code quality (#657)

Posted by GitBox <gi...@apache.org>.
humingcheng commented on a change in pull request #660:
URL: https://github.com/apache/servicecomb-service-center/pull/660#discussion_r450838113



##########
File path: server/plugin/registry/metrics.go
##########
@@ -50,7 +51,7 @@ var (
 			Subsystem:  "db",
 			Name:       "backend_operation_durations_microseconds",
 			Help:       "Latency of backend operation",
-			Objectives: prometheus.DefObjectives,
+			Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},

Review comment:
       没有理解为什么不可以用prometheus.DefObjectives?而且这个硬编码的map重复出现了很多次,建议提取出一个变量。




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-service-center] aseTo2016 commented on a change in pull request #660: add more action for code quality (#657)

Posted by GitBox <gi...@apache.org>.
aseTo2016 commented on a change in pull request #660:
URL: https://github.com/apache/servicecomb-service-center/pull/660#discussion_r450574328



##########
File path: pkg/rest/client.go
##########
@@ -129,11 +129,15 @@ func (client *URLClient) HttpDoWithContext(ctx context.Context, method string, r
 
 	DumpResponse(resp)
 
-	switch resp.Header.Get(HEADER_CONTENT_ENCODING) {
+	switch resp.Header.Get(HeaderContentEncoding) {
 	case "gzip":
 		reader, err := NewGZipBodyReader(resp.Body)
 		if err != nil {
-			io.Copy(ioutil.Discard, resp.Body)
+			_, err = io.Copy(ioutil.Discard, resp.Body)
+			if err != nil {
+				log.Error("", err)
+				return nil, err
+			}
 			resp.Body.Close()

Review comment:
       return 后,body没有close

##########
File path: server/plugin/discovery/servicecenter/syncer.go
##########
@@ -55,45 +55,50 @@ func (c *Syncer) Sync(ctx context.Context) {
 	if len(errs) > 0 {
 		err := fmt.Errorf("%v", errs)
 		log.Errorf(err, "Sync catches errors")
-		alarm.Raise(alarm.IdBackendConnectionRefuse,
+		err = alarm.Raise(alarm.IDBackendConnectionRefuse,
 			alarm.AdditionalContext(err.Error()))
+		if err != nil {
+			log.Error("", err)
+		}
 		if cache == nil {
 			return
 		}
 	}
-	alarm.Clear(alarm.IdBackendConnectionRefuse)
-
+	err := alarm.Clear(alarm.IDBackendConnectionRefuse)

Review comment:
       建议封装个ClearIgnoreError函数,返回出来,只是打印日志,不如封装个函数

##########
File path: scctl/pkg/version/version.go
##########
@@ -30,14 +30,14 @@ var (
 	TOOL_NAME = "scctl"

Review comment:
       TOOL_NAME 这个是不是也可以修改下?

##########
File path: server/service/kv/store.go
##########
@@ -70,3 +70,14 @@ func Exist(ctx context.Context, key string) (bool, error) {
 	}
 	return true, nil
 }
+func Delete(ctx context.Context, key string) (bool, error) {
+	resp, err := backend.Registry().Do(ctx, registry.DEL,
+		registry.WithStrKey(key))
+	if err != nil {
+		return false, err
+	}
+	if resp.Count == 0 {

Review comment:
       直接return resp.Count != 0




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-service-center] tianxiaoliang commented on a change in pull request #660: add more action for code quality (#657)

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #660:
URL: https://github.com/apache/servicecomb-service-center/pull/660#discussion_r450598581



##########
File path: scctl/pkg/version/version.go
##########
@@ -30,14 +30,14 @@ var (
 	TOOL_NAME = "scctl"

Review comment:
       scctl我过滤了,先不扫




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-service-center] tianxiaoliang merged pull request #660: add more action for code quality (#657)

Posted by GitBox <gi...@apache.org>.
tianxiaoliang merged pull request #660:
URL: https://github.com/apache/servicecomb-service-center/pull/660


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-service-center] ChinX commented on a change in pull request #660: add more action for code quality (#657)

Posted by GitBox <gi...@apache.org>.
ChinX commented on a change in pull request #660:
URL: https://github.com/apache/servicecomb-service-center/pull/660#discussion_r448904198



##########
File path: syncer/samples/multi-servicecenters/servicecenter/hello-server/servicecenter/servicecenter.go
##########
@@ -20,20 +20,20 @@ package servicecenter
 import (
 	"context"
 	"fmt"
+	client2 "github.com/apache/servicecomb-service-center/pkg/client/sc"

Review comment:
       Why used client2 as alias here?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-service-center] tianxiaoliang commented on a change in pull request #660: add more action for code quality (#657)

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #660:
URL: https://github.com/apache/servicecomb-service-center/pull/660#discussion_r451268351



##########
File path: server/plugin/registry/metrics.go
##########
@@ -50,7 +51,7 @@ var (
 			Subsystem:  "db",
 			Name:       "backend_operation_durations_microseconds",
 			Help:       "Latency of backend operation",
-			Objectives: prometheus.DefObjectives,
+			Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},

Review comment:
       因为这个变量deprecated




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org