tianxiaoliang commented on a change in pull request #757:
URL: 
https://github.com/apache/servicecomb-service-center/pull/757#discussion_r532305088



##########
File path: cmd/syncer/conf/microservice.yaml
##########
@@ -0,0 +1,3 @@
+servicecomb:
+  service:
+    name: FullSyncronization

Review comment:
       就叫Syncer是否可以

##########
File path: syncer/server/handler.go
##########
@@ -104,3 +188,73 @@ func (s *Server) userEvent(data ...[]byte) (success bool) {
        s.servicecenter.Registry(clusterName, syncData)
        return true
 }
+
+func (s *Server) incrementUserEvent(data ...[]byte) (success bool) {
+       log.Debug("Receive serf user event")
+       clusterName := util.BytesToStringWithNoCopy(data[0])
+
+       // Excludes notifications from self, as the gossip protocol inevitably 
has redundant notifications
+       if s.conf.Cluster == clusterName {
+               return
+       }
+
+       tags := map[string]string{tagKeyClusterName: clusterName}
+       // Get member information and get synchronized data from it
+       members := s.serf.MembersByTags(tags)
+       if len(members) == 0 {
+               log.Warnf("serf member = %s is not found", clusterName)

Review comment:
       这里带f结尾了

##########
File path: syncer/server/http.go
##########
@@ -0,0 +1,44 @@
+package server
+
+import (
+       "github.com/apache/servicecomb-service-center/pkg/log"
+       "github.com/go-chassis/go-chassis/v2"
+       rf "github.com/go-chassis/go-chassis/v2/server/restful"
+       "github.com/go-chassis/openlog"
+       "net/http"
+)
+
+const (
+       Message = "Deliver full synchronization task success!"
+)
+
+func (s *Server) FullSync(b *rf.Context) {
+       s.mux.Lock()
+       s.triggered = true

Review comment:
       加锁意义是?

##########
File path: syncer/server/http.go
##########
@@ -0,0 +1,44 @@
+package server
+
+import (
+       "github.com/apache/servicecomb-service-center/pkg/log"
+       "github.com/go-chassis/go-chassis/v2"
+       rf "github.com/go-chassis/go-chassis/v2/server/restful"
+       "github.com/go-chassis/openlog"
+       "net/http"
+)
+
+const (
+       Message = "Deliver full synchronization task success!"
+)
+
+func (s *Server) FullSync(b *rf.Context) {
+       s.mux.Lock()
+       s.triggered = true
+       s.mux.Unlock()
+       err := b.Write([]byte(Message))
+       if err != nil {
+               log.Error("", err)
+       }
+       return
+}
+
+func (s *Server) URLPatterns() []rf.Route {
+       return []rf.Route{
+               {Method: http.MethodGet, Path: "/v1/syncer/full_sync", 
ResourceFunc: s.FullSync},
+       }
+}
+
+//if you use go run main.go instead of binary run, plz export 
CHASSIS_HOME=/{path}/{to}/server/
+
+func (s *Server) NewHttpServer() {
+       chassis.RegisterSchema("rest", s)
+       if err := chassis.Init(); err != nil {
+               openlog.Fatal("Init failed." + err.Error())

Review comment:
       日志工具不要混用,一个项目只能用一个工具

##########
File path: syncer/server/http.go
##########
@@ -0,0 +1,44 @@
+package server
+
+import (
+       "github.com/apache/servicecomb-service-center/pkg/log"
+       "github.com/go-chassis/go-chassis/v2"
+       rf "github.com/go-chassis/go-chassis/v2/server/restful"
+       "github.com/go-chassis/openlog"
+       "net/http"
+)
+
+const (
+       Message = "Deliver full synchronization task success!"
+)
+
+func (s *Server) FullSync(b *rf.Context) {
+       s.mux.Lock()
+       s.triggered = true
+       s.mux.Unlock()
+       err := b.Write([]byte(Message))
+       if err != nil {
+               log.Error("", err)
+       }
+       return
+}
+
+func (s *Server) URLPatterns() []rf.Route {
+       return []rf.Route{
+               {Method: http.MethodGet, Path: "/v1/syncer/full_sync", 
ResourceFunc: s.FullSync},

Review comment:
       不可以用under score,要用hyphen,另外这个sync是动词,必须用名词

##########
File path: syncer/server/server.go
##########
@@ -85,22 +86,38 @@ type Server struct {
        // Wraps the grpc server
        grpc *grpc.Server
 
+       revisionMap map[string]record
+
        eventQueue []*dump.WatchInstanceChangedEvent
 
+       mapLock sync.RWMutex
+
        queueLock sync.RWMutex
+

Review comment:
       这个Server干吗用的?go chassis支持多server管理,不要单独写个http server了




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