robotLJW commented on a change in pull request #776:
URL:
https://github.com/apache/servicecomb-service-center/pull/776#discussion_r537202925
##########
File path: datasource/mongo/ms.go
##########
@@ -1717,7 +1717,7 @@ func (ds *DataSource) UpdateInstanceStatus(ctx
context.Context, request *pb.Upda
return resp, nil
}
- log.Infof("update instance[%s] status successfully", updateStatusFlag)
+ log.Info(fmt.Sprintf("update instance[%s] status successfully",
updateStatusFlag))
Review comment:
这两个日志打印结果应该是一样的吧,话说为什么要还下面这种格式?能解释下吗,谢谢
##########
File path: datasource/mongo/dep.go
##########
@@ -20,11 +20,12 @@ package mongo
import (
"context"
+ "go.mongodb.org/mongo-driver/mongo/options"
+
Review comment:
包导入顺序,建议顺序:标准库、系统库、第三方库、本项目的库,不同分组之间使用空行分割开
##########
File path: datasource/mongo/dependency_query.go
##########
@@ -0,0 +1,431 @@
+/*
+ * 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 (
+ "context"
+ "fmt"
+ "strings"
+
+ "github.com/apache/servicecomb-service-center/datasource/mongo/client"
+ "github.com/apache/servicecomb-service-center/pkg/log"
+ pb "github.com/go-chassis/cari/discovery"
+ "go.mongodb.org/mongo-driver/bson"
+ "go.mongodb.org/mongo-driver/mongo/options"
+)
+
+type DependencyRelation struct {
+ ctx context.Context
+ domainProject string
+ consumer *pb.MicroService
+ provider *pb.MicroService
+}
+
+type DependencyRelationFilterOpt struct {
Review comment:
个人建议啊,感觉这个能不能和上面的struct合并,初始化也是使用Functional Option
##########
File path: datasource/mongo/dependency_query.go
##########
@@ -0,0 +1,431 @@
+/*
+ * 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 (
+ "context"
+ "fmt"
+ "strings"
+
+ "github.com/apache/servicecomb-service-center/datasource/mongo/client"
+ "github.com/apache/servicecomb-service-center/pkg/log"
+ pb "github.com/go-chassis/cari/discovery"
+ "go.mongodb.org/mongo-driver/bson"
+ "go.mongodb.org/mongo-driver/mongo/options"
+)
+
+type DependencyRelation struct {
+ ctx context.Context
+ domainProject string
+ consumer *pb.MicroService
+ provider *pb.MicroService
+}
+
+type DependencyRelationFilterOpt struct {
+ SameDomainProject bool
+ NonSelf bool
+}
+
+type DependencyRelationFilterOption func(opt DependencyRelationFilterOpt)
DependencyRelationFilterOpt
+
+func NewConsumerDependencyRelation(ctx context.Context, domainProject string,
consumer *pb.MicroService) *DependencyRelation {
+ return NewDependencyRelation(ctx, domainProject, consumer, nil)
+}
+
Review comment:
个人愚见 func NewDependencyRelation(ctx context.Context, domainProject
string, consumer *pb.MicroService,provider *pb.MicroService)
*DependencyRelation 这个会不会更好
##########
File path: datasource/mongo/dependency_query.go
##########
@@ -0,0 +1,431 @@
+/*
+ * 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 (
+ "context"
+ "fmt"
+ "strings"
+
+ "github.com/apache/servicecomb-service-center/datasource/mongo/client"
+ "github.com/apache/servicecomb-service-center/pkg/log"
+ pb "github.com/go-chassis/cari/discovery"
+ "go.mongodb.org/mongo-driver/bson"
+ "go.mongodb.org/mongo-driver/mongo/options"
+)
+
+type DependencyRelation struct {
+ ctx context.Context
+ domainProject string
+ consumer *pb.MicroService
+ provider *pb.MicroService
+}
+
+type DependencyRelationFilterOpt struct {
+ SameDomainProject bool
+ NonSelf bool
+}
+
+type DependencyRelationFilterOption func(opt DependencyRelationFilterOpt)
DependencyRelationFilterOpt
+
+func NewConsumerDependencyRelation(ctx context.Context, domainProject string,
consumer *pb.MicroService) *DependencyRelation {
+ return NewDependencyRelation(ctx, domainProject, consumer, nil)
+}
+
+func NewProviderDependencyRelation(ctx context.Context, domainProject string,
provider *pb.MicroService) *DependencyRelation {
+ return NewDependencyRelation(ctx, domainProject, nil, provider)
+}
+
+func NewDependencyRelation(ctx context.Context, domainProject string, consumer
*pb.MicroService, provider *pb.MicroService) *DependencyRelation {
+ return &DependencyRelation{
Review comment:
如果把上面两个struct合并的话,NewDependencyRelation(ctx context.Context,
domainProject string, consumer *pb.MicroService, provider *pb.MicroService,opts
...func(opt *DependencyRelationFilterOpt)) *DependencyRelation
,具体可以参考https://github.com/go-chassis/go-chassis/pull/925/files
----------------------------------------------------------------
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:
[email protected]