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

修改provider demo,启动多个provider时,指定注册实例id需要保证唯一 #46

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
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
5 changes: 4 additions & 1 deletion examples/quickstart/provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ int ProviderServer::Register() {
register_req.SetHealthCheckType(polaris::kHeartbeatHealthCheck);
register_req.SetTtl(kHeartbeatTtl);
// 实例id不是必填,如果不填,服务端会默认生成一个唯一Id,否则当提供实例id时,需要保证实例id是唯一的
std::string provided_instance_id = "instance-provided-id";
char buff[256] = {0};
memset(buff, 0, sizeof(buff));
snprintf(buff, sizeof(buff), "%s#%s#%s#%d", service_namespace_.c_str(), service_name_.c_str(), host_.c_str(), port_);
std::string provided_instance_id = buff;
register_req.SetInstanceId(provided_instance_id);

// 注册实例
Expand Down