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 2022/05/25 07:22:46 UTC

[GitHub] [servicecomb-service-center] robotLJW commented on a diff in pull request #1302: [feat] Added whitelist function in synchronization

robotLJW commented on code in PR #1302:
URL: https://github.com/apache/servicecomb-service-center/pull/1302#discussion_r881306332


##########
datasource/etcd/ms.go:
##########
@@ -945,11 +942,20 @@ func (ds *MetadataManager) SendManyHeartbeat(ctx context.Context, request *pb.He
 	for heartbeat := range instancesHbRst {
 		count++
 		instanceHbRstArr = append(instanceHbRstArr, heartbeat)
+		// heartbeat sent successfully service should exist
+		microservice, _ := eutil.GetService(ctx, domainProject, heartbeat.ServiceId)
+		// If the synchronization is not in the whitelist, it will be set to fail
+		if !svc.EnableSync(microservice.ServiceName) {
+			util.SetContext(ctx, util.CtxEnableSync, "0")
+		}
 		sendEvent(ctx, sync.UpdateAction, datasource.ResourceHeartbeat,
 			&pb.HeartbeatRequest{ServiceId: heartbeat.ServiceId, InstanceId: heartbeat.InstanceId})
 		if count == noMultiCounter {
 			close(instancesHbRst)
 		}
+		if config.GetBool("sync.enableOnStart", false) {
+			util.SetContext(ctx, util.CtxEnableSync, "1")
+		}

Review Comment:
   因为这个是发送SendManyHeartbeat,这边代表会有很多服务,比如有些服务需要同步有些服务不需要同步,比如上次服务不需要同步,这个服务需要同步,上次的操作不能影响本次



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

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org