This is an automated email from the ASF dual-hosted git repository.
humingcheng pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git
The following commit(s) were added to refs/heads/dev by this push:
new 9083ad29 add re-registration timestamp and update properties when
register with instance id (#1501)
9083ad29 is described below
commit 9083ad29552e95487703c4be56cce2bfdc639ea8
Author: Wanghb1 <[email protected]>
AuthorDate: Wed Mar 5 10:44:48 2025 +0800
add re-registration timestamp and update properties when register with
instance id (#1501)
---
server/service/disco/instance.go | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/server/service/disco/instance.go b/server/service/disco/instance.go
index c2844740..992ff8b6 100644
--- a/server/service/disco/instance.go
+++ b/server/service/disco/instance.go
@@ -40,8 +40,9 @@ import (
)
const (
- defaultMinInterval = 5 * time.Second
- defaultMinTimes = 3
+ defaultMinInterval = 5 * time.Second
+ defaultMinTimes = 3
+ reRegisterTimestamp = "reRegisterTimestamp"
)
var (
@@ -73,7 +74,22 @@ func RegisterInstance(ctx context.Context, in
*pb.RegisterInstanceRequest) (*pb.
if popErr := populateInstanceDefaultValue(ctx, in.Instance); popErr !=
nil {
return nil, popErr
}
- return datasource.GetMetadataManager().RegisterInstance(ctx, in)
+ resp, err := datasource.GetMetadataManager().RegisterInstance(ctx, in)
+ if err != nil {
+ log.Error(fmt.Sprintf("register instance failed, endpoints %v,
host '%s', serviceID %s, operator %s",
+ in.Instance.Endpoints, in.Instance.HostName,
in.Instance.ServiceId, remoteIP), err)
+ return nil, err
+ }
+ // re-register instance with id, should sync properties to peer
+ if len(in.Instance.InstanceId) != 0 {
+ in.Instance.Properties[reRegisterTimestamp] =
time.Now().String()
+ err = PutInstanceProperties(ctx, &pb.UpdateInstancePropsRequest{
+ InstanceId: in.Instance.InstanceId,
+ ServiceId: in.Instance.ServiceId,
+ Properties: in.Instance.Properties,
+ })
+ }
+ return resp, err
}
// instance util