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/11/23 03:04:02 UTC

[GitHub] [servicecomb-service-center] DFSOrange opened a new pull request #754: SCB-2094 implement basic service/rule/schema/tag interface

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


   service,tag融合为单张表,尽可能减少事务操作
   schema涉及和service的同时更新,事务无法避免
   quota,version,service中涉及dep,instance的删除更新待补齐
   当前只保证了基础功能的ut,先不影响性能测试,后续需要补齐分支,且事务ut需要mongo集群。


----------------------------------------------------------------
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 pull request #754: SCB-2094 implement basic service/rule/schema/tag interface

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on pull request #754:
URL: https://github.com/apache/servicecomb-service-center/pull/754#issuecomment-732734910


   还有个冲突解决下


----------------------------------------------------------------
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 pull request #754: SCB-2094 implement basic service/rule/schema/tag interface

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on pull request #754:
URL: https://github.com/apache/servicecomb-service-center/pull/754#issuecomment-732511693


   冲突


----------------------------------------------------------------
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] DFSOrange closed pull request #754: SCB-2094 implement basic service/rule/schema/tag interface

Posted by GitBox <gi...@apache.org>.
DFSOrange closed pull request #754:
URL: https://github.com/apache/servicecomb-service-center/pull/754


   


----------------------------------------------------------------
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 pull request #754: SCB-2094 implement basic service/rule/schema/tag interface

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on pull request #754:
URL: https://github.com/apache/servicecomb-service-center/pull/754#issuecomment-732512974


   另外请在一个pr的上下文里工作,否则reviewer不好继续工作,不要另开pr


----------------------------------------------------------------
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 #754: SCB-2094 implement basic service/rule/schema/tag interface

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


   


----------------------------------------------------------------
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 #754: SCB-2094 implement basic service/rule/schema/tag interface

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



##########
File path: datasource/mongo/util.go
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package mongo
+
+import (
+	pb "github.com/go-chassis/cari/discovery"
+)
+
+func schemasAnalysis(schemas []*pb.Schema, schemasFromDb []*pb.Schema, schemaIDsInService []string) (

Review comment:
       这段代码比较长了,要不然就对里面的代码进行Extract Method,增加易读性,要不然加个方法级注释,写下整个逻辑

##########
File path: datasource/mongo/ms.go
##########
@@ -19,168 +19,1383 @@ package mongo
 
 import (
 	"context"
+	"errors"
+	"fmt"
+	serviceUtil "github.com/apache/servicecomb-service-center/datasource/etcd/util"
+	"github.com/apache/servicecomb-service-center/datasource/mongo/client"
 	"github.com/apache/servicecomb-service-center/datasource/mongo/heartbeat"
+	"github.com/apache/servicecomb-service-center/pkg/log"
+	"github.com/apache/servicecomb-service-center/pkg/util"
+	apt "github.com/apache/servicecomb-service-center/server/core"
+	"github.com/apache/servicecomb-service-center/server/plugin/uuid"
 	pb "github.com/go-chassis/cari/discovery"
+	"go.mongodb.org/mongo-driver/bson"
+	"go.mongodb.org/mongo-driver/mongo/options"
+	"strconv"
+	"time"
 )
 
 func (ds *DataSource) RegisterService(ctx context.Context, request *pb.CreateServiceRequest) (
 	*pb.CreateServiceResponse, error) {
-	return &pb.CreateServiceResponse{}, nil
-}
+	service := request.Service
+	serviceUtil.SetServiceDefaultValue(service)

Review comment:
       这个依赖到了etcd包,说明应该把方法抽出来放到一个公共处,这个填充默认值本就是controller层做的事,不是数据层




----------------------------------------------------------------
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] DFSOrange commented on pull request #754: SCB-2094 implement basic service/rule/schema/tag interface

Posted by GitBox <gi...@apache.org>.
DFSOrange commented on pull request #754:
URL: https://github.com/apache/servicecomb-service-center/pull/754#issuecomment-733524153


   @tianxiaoliang 检视意见已修改


----------------------------------------------------------------
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] DFSOrange commented on pull request #754: SCB-2094 implement basic service/rule/schema/tag interface

Posted by GitBox <gi...@apache.org>.
DFSOrange commented on pull request #754:
URL: https://github.com/apache/servicecomb-service-center/pull/754#issuecomment-732531873


   > 另外请在一个pr的上下文里工作,否则reviewer不好继续工作,不要另开pr
   
   不好意思,之前close了,强推之后不允许我重新打开。


----------------------------------------------------------------
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] DFSOrange edited a comment on pull request #754: SCB-2094 implement basic service/rule/schema/tag interface

Posted by GitBox <gi...@apache.org>.
DFSOrange edited a comment on pull request #754:
URL: https://github.com/apache/servicecomb-service-center/pull/754#issuecomment-732531873


   > 另外请在一个pr的上下文里工作,否则reviewer不好继续工作,不要另开pr
   
   不好意思,之前close了,强推之后不允许我重新打开,下次会注意的


----------------------------------------------------------------
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] DFSOrange commented on pull request #754: SCB-2094 implement basic service/rule/schema/tag interface

Posted by GitBox <gi...@apache.org>.
DFSOrange commented on pull request #754:
URL: https://github.com/apache/servicecomb-service-center/pull/754#issuecomment-732770123


   > 还有个冲突解决下
   
   ok,已解决


----------------------------------------------------------------
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 #754: SCB-2094 implement basic service/rule/schema/tag interface

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



##########
File path: datasource/mongo/client/mongo.go
##########
@@ -146,7 +148,20 @@ func (mc *MongoClient) Insert(ctx context.Context, Table string, document interf
 	if col == nil {
 		return nil, ErrCollectionsNil
 	}
-	return col.InsertOne(ctx, document, opts...)
+	res, err := col.InsertOne(ctx, document, opts...)
+	if err != nil {
+		switch tt := err.(type) {

Review comment:
       这里抽个公共函数,所有的insert就都能用了

##########
File path: datasource/mongo/account.go
##########
@@ -47,21 +46,12 @@ func (ds *DataSource) CreateAccount(ctx context.Context, a *rbacframe.Account) e
 	}
 	a.Password = stringutil.Bytes2str(hash)
 	a.ID = util.GenerateUUID()
-	_, err = client.GetMongoClient().Insert(ctx, CollectionAccount, a)
+	res, err := client.GetMongoClient().Insert(ctx, CollectionAccount, a)
 	if err != nil {
-		switch tt := err.(type) {
-		case mongo.WriteException:
-			if tt.WriteErrors != nil {
-				for _, writeError := range tt.WriteErrors {
-					// The index is setup.The key is repeated.
-					if writeError.Code == DuplicateKey {
-						return datasource.ErrDuplicated
-					}
-				}
-			}
-		default:
-			return err
-		}
+		return err
+	}
+	if res == nil {
+		return datasource.ErrDuplicated

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