From 0dd8e9ac9b37fbf0314e99ea4862b14511525a6f Mon Sep 17 00:00:00 2001 From: rockyang Date: Mon, 6 Mar 2023 11:54:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9provider=20demo=EF=BC=8C?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E5=A4=9A=E4=B8=AAprovider=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E6=B3=A8=E5=86=8C=E5=AE=9E=E4=BE=8Bid?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E4=BF=9D=E8=AF=81=E5=94=AF=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/quickstart/provider.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/quickstart/provider.cpp b/examples/quickstart/provider.cpp index 1b079a3..70a1139 100644 --- a/examples/quickstart/provider.cpp +++ b/examples/quickstart/provider.cpp @@ -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); // 注册实例