This is an automated email from the ASF dual-hosted git repository.

dmwangnima pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/main by this push:
     new 27946829c fix: rename health.proto (#2527)
27946829c is described below

commit 27946829c1a815905f348b7c235319855c5993e4
Author: finalt <[email protected]>
AuthorDate: Sat Dec 2 11:02:06 2023 +0800

    fix: rename health.proto (#2527)
    
    * rename health.proto
    
    * add test for healthServer
    
    * add comment
    
    * add test
    
    * modify comment
    
    * resolve conflicts
    
    * resolve conflicts
    
    * update proto
---
 protocol/triple/health/health_test.go              | 85 ++++++++++++++++++++++
 protocol/triple/health/triple_health/health.pb.go  | 81 +++++++++++----------
 protocol/triple/health/triple_health/health.proto  |  2 +-
 .../triple/health/triple_health/health.triple.go   | 33 ++++++---
 .../triple/internal/client/health_client/main.go   |  6 +-
 5 files changed, 151 insertions(+), 56 deletions(-)

diff --git a/protocol/triple/health/health_test.go 
b/protocol/triple/health/health_test.go
new file mode 100644
index 000000000..d9ee7a4d0
--- /dev/null
+++ b/protocol/triple/health/health_test.go
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package health
+
+import (
+       "sync"
+       "testing"
+       "time"
+)
+import (
+       "github.com/stretchr/testify/assert"
+
+       // If there is a conflict between the healthCheck of Dubbo and the 
healthCheck of gRPC, an error will occur.
+       _ "google.golang.org/grpc/health/grpc_health_v1"
+)
+
+import (
+       healthpb 
"dubbo.apache.org/dubbo-go/v3/protocol/triple/health/triple_health"
+)
+
+const testService = "testService"
+
+func TestSetServingStatus(t *testing.T) {
+       s := NewServer()
+       s.SetServingStatus(testService, healthpb.HealthCheckResponse_SERVING)
+
+       status := s.statusMap[testService]
+       assert.Equal(t, healthpb.HealthCheckResponse_SERVING, status, "status 
for %s is %v, want %v", testService, status, 
healthpb.HealthCheckResponse_SERVING)
+
+       s.SetServingStatus(testService, 
healthpb.HealthCheckResponse_NOT_SERVING)
+       status = s.statusMap[testService]
+       assert.Equal(t, healthpb.HealthCheckResponse_NOT_SERVING, status, 
"status for %s is %v, want %v", testService, status, 
healthpb.HealthCheckResponse_NOT_SERVING)
+}
+
+func TestShutdown(t *testing.T) {
+       s := NewServer()
+       s.SetServingStatus(testService, healthpb.HealthCheckResponse_SERVING)
+       var wg sync.WaitGroup
+       wg.Add(2)
+       // Run SetServingStatus and Shutdown in parallel.
+       go func() {
+               for i := 0; i < 1000; i++ {
+                       s.SetServingStatus(testService, 
healthpb.HealthCheckResponse_SERVING)
+                       time.Sleep(time.Microsecond)
+               }
+               wg.Done()
+       }()
+       go func() {
+               time.Sleep(300 * time.Microsecond)
+               s.Shutdown()
+               wg.Done()
+       }()
+       wg.Wait()
+
+       s.mu.Lock()
+       status := s.statusMap[testService]
+       s.mu.Unlock()
+       assert.Equal(t, healthpb.HealthCheckResponse_NOT_SERVING, status, 
"status for %s is %v, want %v", testService, status, 
healthpb.HealthCheckResponse_NOT_SERVING)
+}
+
+func TestResume(t *testing.T) {
+       s := NewServer()
+       s.SetServingStatus(testService, healthpb.HealthCheckResponse_SERVING)
+       s.Shutdown()
+       status := s.statusMap[testService]
+       assert.Equal(t, healthpb.HealthCheckResponse_NOT_SERVING, status, 
"status for %s is %v, want %v", testService, status, 
healthpb.HealthCheckResponse_NOT_SERVING)
+       s.Resume()
+       status = s.statusMap[testService]
+       assert.Equal(t, healthpb.HealthCheckResponse_SERVING, status, "status 
for %s is %v, want %v", testService, status, 
healthpb.HealthCheckResponse_SERVING)
+}
diff --git a/protocol/triple/health/triple_health/health.pb.go 
b/protocol/triple/health/triple_health/health.pb.go
index a80d66793..24ed18c5e 100644
--- a/protocol/triple/health/triple_health/health.pb.go
+++ b/protocol/triple/health/triple_health/health.pb.go
@@ -148,7 +148,7 @@ type HealthCheckResponse struct {
        sizeCache     protoimpl.SizeCache
        unknownFields protoimpl.UnknownFields
 
-       Status HealthCheckResponse_ServingStatus 
`protobuf:"varint,1,opt,name=status,proto3,enum=grpc.health.v1.HealthCheckResponse_ServingStatus"
 json:"status,omitempty"`
+       Status HealthCheckResponse_ServingStatus 
`protobuf:"varint,1,opt,name=status,proto3,enum=dubbo.health.v1.HealthCheckResponse_ServingStatus"
 json:"status,omitempty"`
 }
 
 func (x *HealthCheckResponse) Reset() {
@@ -193,38 +193,39 @@ func (x *HealthCheckResponse) GetStatus() 
HealthCheckResponse_ServingStatus {
 var File_health_proto protoreflect.FileDescriptor
 
 var file_health_proto_rawDesc = []byte{
-       0x0a, 0x0c, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x2e, 0x70, 0x72, 0x6f, 
0x74, 0x6f, 0x12, 0x0e,
-       0x67, 0x72, 0x70, 0x63, 0x2e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x2e, 
0x76, 0x31, 0x22, 0x2e,
-       0x0a, 0x12, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 
0x6b, 0x52, 0x65, 0x71,
-       0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 
0x69, 0x63, 0x65, 0x18,
-       0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 
0x63, 0x65, 0x22, 0xb1,
-       0x01, 0x0a, 0x13, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 
0x63, 0x6b, 0x52, 0x65,
-       0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, 0x06, 0x73, 0x74, 
0x61, 0x74, 0x75, 0x73,
-       0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x31, 0x2e, 0x67, 0x72, 0x70, 
0x63, 0x2e, 0x68, 0x65,
-       0x61, 0x6c, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x65, 0x61, 0x6c, 
0x74, 0x68, 0x43, 0x68,
-       0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 
0x53, 0x65, 0x72, 0x76,
-       0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 
0x74, 0x61, 0x74, 0x75,
-       0x73, 0x22, 0x4f, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x6e, 0x67, 
0x53, 0x74, 0x61, 0x74,
-       0x75, 0x73, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 
0x4e, 0x10, 0x00, 0x12,
-       0x0b, 0x0a, 0x07, 0x53, 0x45, 0x52, 0x56, 0x49, 0x4e, 0x47, 0x10, 0x01, 
0x12, 0x0f, 0x0a, 0x0b,
-       0x4e, 0x4f, 0x54, 0x5f, 0x53, 0x45, 0x52, 0x56, 0x49, 0x4e, 0x47, 0x10, 
0x02, 0x12, 0x13, 0x0a,
-       0x0f, 0x53, 0x45, 0x52, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 
0x4e, 0x4f, 0x57, 0x4e,
-       0x10, 0x03, 0x32, 0xae, 0x01, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x6c, 0x74, 
0x68, 0x12, 0x50, 0x0a,
-       0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x22, 0x2e, 0x67, 0x72, 0x70, 
0x63, 0x2e, 0x68, 0x65,
-       0x61, 0x6c, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x65, 0x61, 0x6c, 
0x74, 0x68, 0x43, 0x68,
-       0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 
0x2e, 0x67, 0x72, 0x70,
-       0x63, 0x2e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 
0x48, 0x65, 0x61, 0x6c,
-       0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 
0x6e, 0x73, 0x65, 0x12,
-       0x52, 0x0a, 0x05, 0x57, 0x61, 0x74, 0x63, 0x68, 0x12, 0x22, 0x2e, 0x67, 
0x72, 0x70, 0x63, 0x2e,
+       0x0a, 0x0c, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x2e, 0x70, 0x72, 0x6f, 
0x74, 0x6f, 0x12, 0x0f,
+       0x64, 0x75, 0x62, 0x62, 0x6f, 0x2e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 
0x2e, 0x76, 0x31, 0x22,
+       0x2e, 0x0a, 0x12, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 
0x63, 0x6b, 0x52, 0x65,
+       0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 
0x76, 0x69, 0x63, 0x65,
+       0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 
0x69, 0x63, 0x65, 0x22,
+       0xb2, 0x01, 0x0a, 0x13, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 
0x65, 0x63, 0x6b, 0x52,
+       0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4a, 0x0a, 0x06, 0x73, 
0x74, 0x61, 0x74, 0x75,
+       0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x32, 0x2e, 0x64, 0x75, 
0x62, 0x62, 0x6f, 0x2e,
        0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x65, 
0x61, 0x6c, 0x74, 0x68,
-       0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 
0x1a, 0x23, 0x2e, 0x67,
-       0x72, 0x70, 0x63, 0x2e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x2e, 0x76, 
0x31, 0x2e, 0x48, 0x65,
-       0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 
0x70, 0x6f, 0x6e, 0x73,
-       0x65, 0x30, 0x01, 0x42, 0x43, 0x5a, 0x41, 0x64, 0x75, 0x62, 0x62, 0x6f, 
0x2e, 0x61, 0x70, 0x61,
-       0x63, 0x68, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x64, 0x75, 0x62, 0x62, 
0x6f, 0x2d, 0x67, 0x6f,
-       0x2f, 0x76, 0x33, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 
0x2f, 0x74, 0x72, 0x69,
-       0x70, 0x6c, 0x65, 0x2f, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x2f, 0x74, 
0x72, 0x69, 0x70, 0x6c,
-       0x65, 0x5f, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x62, 0x06, 0x70, 0x72, 
0x6f, 0x74, 0x6f, 0x33,
+       0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 
0x65, 0x2e, 0x53, 0x65,
+       0x72, 0x76, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 
0x06, 0x73, 0x74, 0x61,
+       0x74, 0x75, 0x73, 0x22, 0x4f, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 
0x6e, 0x67, 0x53, 0x74,
+       0x61, 0x74, 0x75, 0x73, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 
0x4f, 0x57, 0x4e, 0x10,
+       0x00, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x45, 0x52, 0x56, 0x49, 0x4e, 0x47, 
0x10, 0x01, 0x12, 0x0f,
+       0x0a, 0x0b, 0x4e, 0x4f, 0x54, 0x5f, 0x53, 0x45, 0x52, 0x56, 0x49, 0x4e, 
0x47, 0x10, 0x02, 0x12,
+       0x13, 0x0a, 0x0f, 0x53, 0x45, 0x52, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x55, 
0x4e, 0x4b, 0x4e, 0x4f,
+       0x57, 0x4e, 0x10, 0x03, 0x32, 0xb2, 0x01, 0x0a, 0x06, 0x48, 0x65, 0x61, 
0x6c, 0x74, 0x68, 0x12,
+       0x52, 0x0a, 0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x23, 0x2e, 0x64, 
0x75, 0x62, 0x62, 0x6f,
+       0x2e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x48, 
0x65, 0x61, 0x6c, 0x74,
+       0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 
0x74, 0x1a, 0x24, 0x2e,
+       0x64, 0x75, 0x62, 0x62, 0x6f, 0x2e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 
0x2e, 0x76, 0x31, 0x2e,
+       0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 
0x65, 0x73, 0x70, 0x6f,
+       0x6e, 0x73, 0x65, 0x12, 0x54, 0x0a, 0x05, 0x57, 0x61, 0x74, 0x63, 0x68, 
0x12, 0x23, 0x2e, 0x64,
+       0x75, 0x62, 0x62, 0x6f, 0x2e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x2e, 
0x76, 0x31, 0x2e, 0x48,
+       0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 
0x71, 0x75, 0x65, 0x73,
+       0x74, 0x1a, 0x24, 0x2e, 0x64, 0x75, 0x62, 0x62, 0x6f, 0x2e, 0x68, 0x65, 
0x61, 0x6c, 0x74, 0x68,
+       0x2e, 0x76, 0x31, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 
0x65, 0x63, 0x6b, 0x52,
+       0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x42, 0x43, 0x5a, 
0x41, 0x64, 0x75, 0x62,
+       0x62, 0x6f, 0x2e, 0x61, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2e, 0x6f, 0x72, 
0x67, 0x2f, 0x64, 0x75,
+       0x62, 0x62, 0x6f, 0x2d, 0x67, 0x6f, 0x2f, 0x76, 0x33, 0x2f, 0x70, 0x72, 
0x6f, 0x74, 0x6f, 0x63,
+       0x6f, 0x6c, 0x2f, 0x74, 0x72, 0x69, 0x70, 0x6c, 0x65, 0x2f, 0x68, 0x65, 
0x61, 0x6c, 0x74, 0x68,
+       0x2f, 0x74, 0x72, 0x69, 0x70, 0x6c, 0x65, 0x5f, 0x68, 0x65, 0x61, 0x6c, 
0x74, 0x68, 0x62, 0x06,
+       0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -242,16 +243,16 @@ func file_health_proto_rawDescGZIP() []byte {
 var file_health_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
 var file_health_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
 var file_health_proto_goTypes = []interface{}{
-       (HealthCheckResponse_ServingStatus)(0), // 0: 
grpc.health.v1.HealthCheckResponse.ServingStatus
-       (*HealthCheckRequest)(nil),             // 1: 
grpc.health.v1.HealthCheckRequest
-       (*HealthCheckResponse)(nil),            // 2: 
grpc.health.v1.HealthCheckResponse
+       (HealthCheckResponse_ServingStatus)(0), // 0: 
dubbo.health.v1.HealthCheckResponse.ServingStatus
+       (*HealthCheckRequest)(nil),             // 1: 
dubbo.health.v1.HealthCheckRequest
+       (*HealthCheckResponse)(nil),            // 2: 
dubbo.health.v1.HealthCheckResponse
 }
 var file_health_proto_depIdxs = []int32{
-       0, // 0: grpc.health.v1.HealthCheckResponse.status:type_name -> 
grpc.health.v1.HealthCheckResponse.ServingStatus
-       1, // 1: grpc.health.v1.Health.Check:input_type -> 
grpc.health.v1.HealthCheckRequest
-       1, // 2: grpc.health.v1.Health.Watch:input_type -> 
grpc.health.v1.HealthCheckRequest
-       2, // 3: grpc.health.v1.Health.Check:output_type -> 
grpc.health.v1.HealthCheckResponse
-       2, // 4: grpc.health.v1.Health.Watch:output_type -> 
grpc.health.v1.HealthCheckResponse
+       0, // 0: dubbo.health.v1.HealthCheckResponse.status:type_name -> 
dubbo.health.v1.HealthCheckResponse.ServingStatus
+       1, // 1: dubbo.health.v1.Health.Check:input_type -> 
dubbo.health.v1.HealthCheckRequest
+       1, // 2: dubbo.health.v1.Health.Watch:input_type -> 
dubbo.health.v1.HealthCheckRequest
+       2, // 3: dubbo.health.v1.Health.Check:output_type -> 
dubbo.health.v1.HealthCheckResponse
+       2, // 4: dubbo.health.v1.Health.Watch:output_type -> 
dubbo.health.v1.HealthCheckResponse
        3, // [3:5] is the sub-list for method output_type
        1, // [1:3] is the sub-list for method input_type
        1, // [1:1] is the sub-list for extension type_name
diff --git a/protocol/triple/health/triple_health/health.proto 
b/protocol/triple/health/triple_health/health.proto
index e3ef667fc..22b8b42c1 100644
--- a/protocol/triple/health/triple_health/health.proto
+++ b/protocol/triple/health/triple_health/health.proto
@@ -20,7 +20,7 @@
 
 syntax = "proto3";
 
-package grpc.health.v1;
+package dubbo.health.v1;
 
 option go_package = 
"dubbo.apache.org/dubbo-go/v3/protocol/triple/health/triple_health";
 
diff --git a/protocol/triple/health/triple_health/health.triple.go 
b/protocol/triple/health/triple_health/health.triple.go
index 908737fcc..25a226452 100644
--- a/protocol/triple/health/triple_health/health.triple.go
+++ b/protocol/triple/health/triple_health/health.triple.go
@@ -17,7 +17,7 @@
 
 // Code generated by protoc-gen-triple. DO NOT EDIT.
 //
-// Source: protocol\triple\health\triple_health\health.proto
+// Source: health.proto
 package triple_health
 
 import (
@@ -26,7 +26,9 @@ import (
 )
 
 import (
+       "dubbo.apache.org/dubbo-go/v3"
        "dubbo.apache.org/dubbo-go/v3/client"
+       "dubbo.apache.org/dubbo-go/v3/common"
        "dubbo.apache.org/dubbo-go/v3/common/constant"
        "dubbo.apache.org/dubbo-go/v3/protocol/triple/triple_protocol"
        "dubbo.apache.org/dubbo-go/v3/server"
@@ -41,7 +43,7 @@ const _ = triple_protocol.IsAtLeastVersion0_1_0
 
 const (
        // HealthName is the fully-qualified name of the Health service.
-       HealthName = "grpc.health.v1.Health"
+       HealthName = "dubbo.health.v1.Health"
 )
 
 // These constants are the fully-qualified names of the RPCs defined in this 
package. They're
@@ -53,9 +55,9 @@ const (
 // period.
 const (
        // HealthCheckProcedure is the fully-qualified name of the Health's 
Check RPC.
-       HealthCheckProcedure = "/grpc.health.v1.Health/Check"
+       HealthCheckProcedure = "/dubbo.health.v1.Health/Check"
        // HealthWatchProcedure is the fully-qualified name of the Health's 
Watch RPC.
-       HealthWatchProcedure = "/grpc.health.v1.Health/Watch"
+       HealthWatchProcedure = "/dubbo.health.v1.Health/Watch"
 )
 
 var (
@@ -66,24 +68,27 @@ var (
        _ Health_WatchServer = (*HealthWatchServer)(nil)
 )
 
-// Health is a client for the grpc.health.v1.Health service.
+// Health is a client for the dubbo.health.v1.Health service.
 type Health interface {
        Check(ctx context.Context, req *HealthCheckRequest, opts 
...client.CallOption) (*HealthCheckResponse, error)
        Watch(ctx context.Context, req *HealthCheckRequest, opts 
...client.CallOption) (Health_WatchClient, error)
 }
 
-// NewHealth constructs a client for the grpc.health.v1.Health service.
+// NewHealth constructs a client for the dubbo.health.v1.Health service.
 func NewHealth(cli *client.Client, opts ...client.ReferenceOption) (Health, 
error) {
-       conn, err := cli.Dial("grpc.health.v1.Health", opts...)
+       conn, err := cli.DialWithInfo("dubbo.health.v1.Health", 
&Health_ClientInfo, opts...)
        if err != nil {
                return nil, err
        }
-
        return &HealthImpl{
                conn: conn,
        }, nil
 }
 
+func SetConsumerService(srv common.RPCService) {
+       dubbo.SetConsumerServiceWithInfo(srv, &Health_ClientInfo)
+}
+
 // HealthImpl implements Health.
 type HealthImpl struct {
        conn *client.Connection
@@ -138,15 +143,15 @@ func (cli *HealthWatchClient) Conn() 
(triple_protocol.StreamingClientConn, error
 }
 
 var Health_ClientInfo = client.ClientInfo{
-       InterfaceName: "grpc.health.v1.Health",
+       InterfaceName: "dubbo.health.v1.Health",
        MethodNames:   []string{"Check", "Watch"},
        ConnectionInjectFunc: func(dubboCliRaw interface{}, conn 
*client.Connection) {
-               dubboCli := dubboCliRaw.(HealthImpl)
+               dubboCli := dubboCliRaw.(*HealthImpl)
                dubboCli.conn = conn
        },
 }
 
-// HealthHandler is an implementation of the grpc.health.v1.Health service.
+// HealthHandler is an implementation of the dubbo.health.v1.Health service.
 type HealthHandler interface {
        Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, 
error)
        Watch(context.Context, *HealthCheckRequest, Health_WatchServer) error
@@ -156,6 +161,10 @@ func RegisterHealthHandler(srv *server.Server, hdlr 
HealthHandler, opts ...serve
        return srv.Register(hdlr, &Health_ServiceInfo, opts...)
 }
 
+func SetProviderService(srv common.RPCService) {
+       dubbo.SetProviderServiceWithInfo(srv, &Health_ServiceInfo)
+}
+
 type Health_WatchServer interface {
        Send(*HealthCheckResponse) error
        ResponseHeader() http.Header
@@ -172,7 +181,7 @@ func (g *HealthWatchServer) Send(msg *HealthCheckResponse) 
error {
 }
 
 var Health_ServiceInfo = server.ServiceInfo{
-       InterfaceName: "grpc.health.v1.Health",
+       InterfaceName: "dubbo.health.v1.Health",
        ServiceType:   (*HealthHandler)(nil),
        Methods: []server.MethodInfo{
                {
diff --git a/protocol/triple/internal/client/health_client/main.go 
b/protocol/triple/internal/client/health_client/main.go
index 7fc0dc2bd..0b36574bc 100644
--- a/protocol/triple/internal/client/health_client/main.go
+++ b/protocol/triple/internal/client/health_client/main.go
@@ -43,11 +43,11 @@ func main() {
                panic(err)
        }
 
-       check, err := svc.Check(context.Background(), 
&health.HealthCheckRequest{Service: "grpc.health.v1.Health"})
+       check, err := svc.Check(context.Background(), 
&health.HealthCheckRequest{Service: "dubbo.health.v1.Health"})
        if err != nil {
                logger.Error(err)
        } else {
-               logger.Info("grpc.health.v1.Health's health", check.String())
+               logger.Info("dubbo.health.v1.Health's health", check.String())
        }
        check, err = svc.Check(context.Background(), 
&health.HealthCheckRequest{Service: "greet.GreetService"})
        if err != nil {
@@ -61,7 +61,7 @@ func main() {
                logger.Error(err)
        } else {
                if watch.Recv() {
-                       logger.Info("grpc.health.v1.Health's health", 
watch.Msg().String())
+                       logger.Info("dubbo.health.v1.Health's health", 
watch.Msg().String())
                }
        }
        watch, err = svc.Watch(context.Background(), 
&health.HealthCheckRequest{Service: "greet.GreetService"})

Reply via email to