Skip to content

Commit

Permalink
Merge pull request #1688 from chuntaojun/fix_issue_1687
Browse files Browse the repository at this point in the history
[ISSUE #1687] Fix the problem that the heartbeat cannot be reported
  • Loading branch information
LaurenceLiZhixin authored Jan 7, 2022
2 parents c4fa4a0 + 7801449 commit 66b43aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions registry/polaris/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ var localIP = ""

const (
// RegistryConnDelay registry connection delay
RegistryConnDelay = 3
RegistryConnDelay = 3
defaultHeartbeatIntervalSec = 5
)

func init() {
Expand Down Expand Up @@ -291,7 +292,7 @@ func createRegisterParam(url *common.URL, serviceName string) *api.InstanceRegis
})
metadata[constant.PolarisDubboPath] = url.Path

return &api.InstanceRegisterRequest{
req := &api.InstanceRegisterRequest{
InstanceRegisterRequest: model.InstanceRegisterRequest{
Service: serviceName,
Namespace: url.GetParam(constant.PolarisNamespace, constant.PolarisDefaultNamespace),
Expand All @@ -301,6 +302,10 @@ func createRegisterParam(url *common.URL, serviceName string) *api.InstanceRegis
Metadata: metadata,
},
}

req.SetTTL(defaultHeartbeatIntervalSec)

return req
}

// createDeregisterParam convert dubbo url to polaris instance deregister request
Expand Down
4 changes: 2 additions & 2 deletions registry/polaris/service_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ func (polaris *polarisServiceDiscovery) Destroy() error {
inst.cancel()

err := polaris.Unregister(inst.instance)
logger.Infof("Unregister nacos instance:%+v", inst)
logger.Infof("Unregister polaris instance:%+v", inst)
if err != nil {
logger.Errorf("Unregister nacos instance:%+v, err:%+v", inst, err)
logger.Errorf("Unregister polaris instance:%+v, err:%+v", inst, err)
}
}
polaris.provider.Destroy()
Expand Down

0 comments on commit 66b43aa

Please sign in to comment.