lilai23 commented on a change in pull request #773:
URL:
https://github.com/apache/servicecomb-service-center/pull/773#discussion_r537278067
##########
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:
这个是protobuf插件根据pb文件自动生成函数,应该是要保留的
----------------------------------------------------------------
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]