Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #219] fix:修复服务列表监听可能导致OOM #220

Merged
merged 5 commits into from
Dec 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: 添加就近路由支持文档
  • Loading branch information
chuntaojun committed Dec 4, 2024
commit 62c95dc5b53fadc1e2a35c2f9e3de7f91a485f1b
17 changes: 17 additions & 0 deletions examples/quickstart/provider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,23 @@ func (svr *PolarisProvider) deregisterService() {
log.Fatalf("fail to deregister instance, err is %v", err)
}
log.Printf("deregister successfully.")
go svr.doHeartbeat()
}

func (svr *PolarisProvider) doHeartbeat() {
log.Printf("start to invoke heartbeat operation")
ticker := time.NewTicker(time.Duration(5 * time.Second))
for range ticker.C {
if !svr.isShutdown {
heartbeatRequest := &polaris.InstanceHeartbeatRequest{}
heartbeatRequest.Namespace = namespace
heartbeatRequest.Service = service
heartbeatRequest.Host = svr.host
heartbeatRequest.Port = svr.port
heartbeatRequest.ServiceToken = token
svr.provider.Heartbeat(heartbeatRequest)
}
}
}

func (svr *PolarisProvider) runMainLoop() {
Expand Down