robotLJW commented on a change in pull request #773:
URL: 
https://github.com/apache/servicecomb-service-center/pull/773#discussion_r535767448



##########
File path: syncer/server/handler.go
##########
@@ -21,9 +21,9 @@ import (
        "context"
        "crypto/tls"
        "fmt"
-       "math"
        "strconv"
-       "time"
+
+       "github.com/apache/servicecomb-service-center/pkg/dump"
 

Review comment:
       包导入顺序,建议顺序:标准库、系统库、第三方库、本项目的库,不同分组之间使用空行分割开

##########
File path: syncer/server/handler.go
##########
@@ -70,69 +71,16 @@ func (s *Server) tickHandler() {
        }
 }
 
-func (s *Server) DataRemoveTickHandler() chan bool {
-       ticker := time.NewTicker(time.Second * 30)
-       stopChan := make(chan bool)
-       go func(trick *time.Ticker) {
-               //defer ticker.Stop()
-               for {
-                       select {
-                       case <-ticker.C:
-                               s.eventQueueDataRemoveTickHandler()
-                               log.Info(fmt.Sprintf("size of records map = %d, 
size of events slice = %d", len(s.revisionMap), len(s.eventQueue)))
-                       case stop := <-stopChan:
-                               if stop {
-                                       log.Info("data remove ticker stop")
-                                       return
-                               }
-                       case <-context.Background().Done():
-                               return
-                       }
-               }
-       }(ticker)
-       return stopChan
-}
-
-func (s *Server) eventQueueDataRemoveTickHandler() {
-       if len(s.revisionMap) == 0 || len(s.eventQueue) == 0 {
-               log.Info("RevisionMap or EventQueue is empty")
-               return
-       }
-
-       log.Info(fmt.Sprintf("length of map : %d", len(s.revisionMap)))
-       var minRevision int64 = math.MaxInt64
-       for _, value := range s.revisionMap {
-               var tempRevision = value.revision
-               if tempRevision < minRevision {
-                       minRevision = tempRevision
-               }
-       }
-
-       log.Info(fmt.Sprintf("revision of item will remove : %d", minRevision))
-
-       j := 0
-       for _, value := range s.eventQueue {
-               var tempRevision = value.Revision
-               if tempRevision == minRevision {
-                       break
-               }
-               j++
-       }
-       s.eventQueue = s.eventQueue[j:]
-       log.Info(fmt.Sprintf("size of event queue : %d", len(s.eventQueue)))
-       if len(s.eventQueue) > 0 {
-               log.Info(fmt.Sprintf("revision of first element in event queue 
: %d", s.eventQueue[0].Revision))
-       }
-}
-
 // Pull returns sync data of servicecenter
-func (s *Server) Pull(context.Context, *pb.PullRequest) (*pb.SyncData, error) {
+func (s *Server) Pull(ctx context.Context, req *pb.PullRequest) (*pb.SyncData, 
error) {
+       if _, ok := s.channelMap[req.GetAddr()]; !ok {
+               s.channelMap[req.GetAddr()] = make(chan 
*dump.WatchInstanceChangedEvent, BufferSize)
+       }

Review comment:
       提一个疑问不一定是问题,我看这边返回error都是nil,是不是可以不要?还是其他场景下会返回其它错误




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


Reply via email to