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 2021/01/11 08:04:55 UTC

[GitHub] [servicecomb-service-center] GuoYL123 opened a new pull request #826: [SCD-2133] add scene id / add custome err

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


   (cherry picked from commit 952e2de3d2b48d17f9de13a05b6c5e9142eb0439)
   
   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).
    - [ ] Never comment source code, delete it.
    - [ ] UT should has "context, subject, expected result" result as test case name, when you call t.Run().
   ---
   


----------------------------------------------------------------
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] GuoYL123 commented on a change in pull request #826: [SCD-2133] add scene id / add custome err

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



##########
File path: server/service/gov/mock/mock.go
##########
@@ -98,14 +98,18 @@ func (d *Distributor) Display(project, app, env string) ([]byte, error) {
 func (d *Distributor) List(kind, project, app, env string) ([]byte, error) {
 	r := make([]*gov.Policy, 0, len(d.lbPolicies))
 	for _, g := range d.lbPolicies {
-		if g.Kind == kind && g.Selector.App == app && g.Selector.Environment == env {
+		if check(g, kind, app, env) {
 			r = append(r, g)
 		}
 	}
 	b, _ := json.MarshalIndent(r, "", "  ")
 	return b, nil
 }
 
+func check(g *gov.Policy, kind, app, env string) bool {

Review comment:
       done

##########
File path: server/service/gov/kie/kie_distributor.go
##########
@@ -42,8 +45,13 @@ func (d *Distributor) Create(kind, project string, spec []byte) ([]byte, error)
 	if err != nil {
 		return nil, err
 	}
+	if kind == MatchGroup {
+		err = d.generateID(project, p)
+	}
+	if err != nil {

Review comment:
       done

##########
File path: server/service/gov/kie/kie_distributor.go
##########
@@ -241,6 +249,70 @@ func (d *Distributor) listDataByKind(kind, project, app, env string) (*kie.KVRes
 	return d.client.List(context.TODO(), ops...)
 }
 
+func (d *Distributor) generateID(project string, p *gov.Policy) error {
+	if p.Name != "" {
+		return nil
+	}
+	list, _, err := d.listDataByKind(MatchGroup, project, p.Selector.App, p.Selector.Environment)
+	if err != nil {
+		return err
+	}
+	alias, err := getAlias(p)
+	if err != nil {
+		return err
+	}
+	var id string
+	for {
+		var repeat bool
+		id = getID()
+		for _, datum := range list.Data {
+			itemP, err := d.transform(datum, MatchGroup)
+			if err != nil {
+				return err
+			}
+			temp, err := getAlias(itemP)

Review comment:
       done




----------------------------------------------------------------
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 #826: [SCD-2133] add scene id / add custome err

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



##########
File path: server/service/gov/kie/kie_distributor.go
##########
@@ -241,6 +249,70 @@ func (d *Distributor) listDataByKind(kind, project, app, env string) (*kie.KVRes
 	return d.client.List(context.TODO(), ops...)
 }
 
+func (d *Distributor) generateID(project string, p *gov.Policy) error {
+	if p.Name != "" {
+		return nil
+	}
+	list, _, err := d.listDataByKind(MatchGroup, project, p.Selector.App, p.Selector.Environment)
+	if err != nil {
+		return err
+	}
+	alias, err := getAlias(p)
+	if err != nil {
+		return err
+	}
+	var id string
+	for {
+		var repeat bool
+		id = getID()
+		for _, datum := range list.Data {
+			itemP, err := d.transform(datum, MatchGroup)
+			if err != nil {
+				return err
+			}
+			temp, err := getAlias(itemP)

Review comment:
       不判重




----------------------------------------------------------------
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 #826: [SCD-2133] add scene id / add custome err

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



##########
File path: server/service/gov/kie/kie_distributor.go
##########
@@ -42,8 +45,13 @@ func (d *Distributor) Create(kind, project string, spec []byte) ([]byte, error)
 	if err != nil {
 		return nil, err
 	}
+	if kind == MatchGroup {
+		err = d.generateID(project, p)
+	}
+	if err != nil {

Review comment:
       err位置不对,放到49之后

##########
File path: server/service/gov/mock/mock.go
##########
@@ -98,14 +98,18 @@ func (d *Distributor) Display(project, app, env string) ([]byte, error) {
 func (d *Distributor) List(kind, project, app, env string) ([]byte, error) {
 	r := make([]*gov.Policy, 0, len(d.lbPolicies))
 	for _, g := range d.lbPolicies {
-		if g.Kind == kind && g.Selector.App == app && g.Selector.Environment == env {
+		if check(g, kind, app, env) {
 			r = append(r, g)
 		}
 	}
 	b, _ := json.MarshalIndent(r, "", "  ")
 	return b, nil
 }
 
+func check(g *gov.Policy, kind, app, env string) bool {

Review comment:
       这个函数名不易读,不能一下子理解业务逻辑,要有具体的意义




----------------------------------------------------------------
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 #826: [SCD-2133] add scene id / add custome err

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


   


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