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/12/25 10:15:37 UTC

[GitHub] [servicecomb-service-center] DFSOrange opened a new pull request #791: 1226

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


   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] tianxiaoliang commented on a change in pull request #791: [SCB-2094] cache support get instances

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



##########
File path: datasource/mongo/sd/mongo_cache.go
##########
@@ -18,86 +18,131 @@
 package sd
 
 import (
-	"sync"
-
-	"github.com/apache/servicecomb-service-center/pkg/util"
+	"github.com/patrickmn/go-cache"
 )
 
 // MongoCache implements Cache.
 // MongoCache is dedicated to stores service discovery data,
 // e.g. service, instance, lease.
 type MongoCache struct {
-	Options       *Options
-	name          string
-	store         map[string]interface{}
-	documentStore map[string]string
-	rwMux         sync.RWMutex
-	dirty         bool
+	Options  *Options
+	name     string
+	store    *cache.Cache
+	docStore *cache.Cache
+	//the key is index,the value is a list of bussinessID
+	indexStore *cache.Cache

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] DFSOrange commented on a change in pull request #791: [SCB-2094] cache support get instances

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



##########
File path: datasource/mongo/sd/mongo_cache.go
##########
@@ -18,86 +18,131 @@
 package sd
 
 import (
-	"sync"
-
-	"github.com/apache/servicecomb-service-center/pkg/util"
+	"github.com/patrickmn/go-cache"
 )
 
 // MongoCache implements Cache.
 // MongoCache is dedicated to stores service discovery data,
 // e.g. service, instance, lease.
 type MongoCache struct {
-	Options       *Options
-	name          string
-	store         map[string]interface{}
-	documentStore map[string]string
-	rwMux         sync.RWMutex
-	dirty         bool
+	Options  *Options
+	name     string
+	store    *cache.Cache
+	docStore *cache.Cache
+	//the key is index,the value is a list of bussinessID
+	indexStore *cache.Cache

Review comment:
       > 注释内容与实际实现不符
   
   已修改到mongocache注释中,cache放正向和方向映射




----------------------------------------------------------------
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 a change in pull request #791: [SCB-2094] cache support get instances

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



##########
File path: datasource/mongo/sd/mongo_cache.go
##########
@@ -18,86 +18,131 @@
 package sd
 
 import (
-	"sync"
-
-	"github.com/apache/servicecomb-service-center/pkg/util"
+	"github.com/patrickmn/go-cache"
 )
 
 // MongoCache implements Cache.
 // MongoCache is dedicated to stores service discovery data,
 // e.g. service, instance, lease.
 type MongoCache struct {
-	Options       *Options
-	name          string
-	store         map[string]interface{}
-	documentStore map[string]string
-	rwMux         sync.RWMutex
-	dirty         bool
+	Options  *Options
+	name     string
+	store    *cache.Cache
+	docStore *cache.Cache
+	//the key is index,the value is a list of bussinessID
+	indexStore *cache.Cache

Review comment:
       已修改到mongocache注释中,一份cache放正向和方向映射




----------------------------------------------------------------
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 a change in pull request #791: [SCB-2094] cache support get instances

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



##########
File path: datasource/mongo/sd/types.go
##########
@@ -84,6 +86,7 @@ type ResumeToken struct {
 type MongoInfo struct {

Review comment:
       > MongoInfo 完全可以用Resource 尽量避免重复定义长得相似的strcut
   
   已删除mongoinfo




----------------------------------------------------------------
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 a change in pull request #791: [SCB-2094] cache support get instances

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



##########
File path: datasource/mongo/sd/types.go
##########
@@ -43,6 +43,7 @@ func RegisterType(name string) {
 type MongoEvent struct {
 	DocumentID string
 	ResourceID string
+	Index      string

Review comment:
       > mongo event需要value么?
   
   这里的event可能名字有歧义,不仅用于syncer的同步,还用于cache的更新。




----------------------------------------------------------------
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] lilai23 commented on a change in pull request #791: [SCB-2094] cache support get instances

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



##########
File path: datasource/mongo/ms.go
##########
@@ -27,6 +27,8 @@ import (
 	"strings"
 	"time"
 
+	"github.com/apache/servicecomb-service-center/datasource/mongo/sd"
+

Review comment:
       多余空行

##########
File path: datasource/mongo/sd/mongo_cacher.go
##########
@@ -21,10 +21,11 @@ import (
 	"context"
 	"errors"
 	"fmt"
-	"github.com/apache/servicecomb-service-center/datasource/sdcommon"
 	"sync"
 	"time"
 
+	"github.com/apache/servicecomb-service-center/datasource/sdcommon"
+

Review comment:
       多余空行

##########
File path: datasource/mongo/sd/types.go
##########
@@ -18,9 +18,10 @@
 package sd
 
 import (
-	"github.com/apache/servicecomb-service-center/datasource/sdcommon"
 	"time"
 
+	"github.com/apache/servicecomb-service-center/datasource/sdcommon"
+

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] DFSOrange commented on a change in pull request #791: [SCB-2094] cache support get instances

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



##########
File path: datasource/sdcommon/common.go
##########
@@ -23,6 +23,6 @@ const (
 	DefaultMetricsInterval   = 30 * time.Second
 
 	MinWaitInterval = 1 * time.Second
-	EventBlockSize  = 1000
+	EventBlockSize  = 800

Review comment:
       the channal have size limit




----------------------------------------------------------------
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 #791: [SCB-2094] cache support get instances

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



##########
File path: datasource/mongo/sd/types.go
##########
@@ -43,6 +43,7 @@ func RegisterType(name string) {
 type MongoEvent struct {
 	DocumentID string
 	ResourceID string
+	Index      string

Review comment:
       mongo event需要value么?

##########
File path: datasource/mongo/sd/types.go
##########
@@ -84,6 +86,7 @@ type ResumeToken struct {
 type MongoInfo struct {

Review comment:
       MongoInfo  完全可以用Resource 尽量避免重复定义长得相似的strcut

##########
File path: datasource/mongo/sd/mongo_cache.go
##########
@@ -27,12 +27,13 @@ import (
 // MongoCache is dedicated to stores service discovery data,
 // e.g. service, instance, lease.
 type MongoCache struct {
-	Options       *Options
-	name          string
-	store         map[string]interface{}
-	documentStore map[string]string
-	rwMux         sync.RWMutex
-	dirty         bool
+	Options           *Options

Review comment:
       cache 没必要自研吧,已经有cache的通用库了




----------------------------------------------------------------
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 #791: [SCB-2094] cache support get instances

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


   


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