dubbo.apache.org/dubbo-go/v3@v3.1.1/protocol/dubbo3/health/triple_health_v1/health_triple.pb.go (about) 1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 // Code generated by protoc-gen-go-triple. DO NOT EDIT. 19 // versions: 20 // - protoc-gen-go-triple v1.0.8 21 // - protoc v3.21.12 22 // source: health.proto 23 24 package triple_health_v1 25 26 import ( 27 context "context" 28 fmt "fmt" 29 ) 30 31 import ( 32 grpc_go "github.com/dubbogo/grpc-go" 33 codes "github.com/dubbogo/grpc-go/codes" 34 metadata "github.com/dubbogo/grpc-go/metadata" 35 status "github.com/dubbogo/grpc-go/status" 36 37 common "github.com/dubbogo/triple/pkg/common" 38 constant "github.com/dubbogo/triple/pkg/common/constant" 39 triple "github.com/dubbogo/triple/pkg/triple" 40 ) 41 42 import ( 43 constant1 "dubbo.apache.org/dubbo-go/v3/common/constant" 44 protocol "dubbo.apache.org/dubbo-go/v3/protocol" 45 dubbo3 "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3" 46 invocation "dubbo.apache.org/dubbo-go/v3/protocol/invocation" 47 ) 48 49 // This is a compile-time assertion to ensure that this generated file 50 // is compatible with the grpc package it is being compiled against. 51 const _ = grpc_go.SupportPackageIsVersion7 52 53 // HealthClient is the client API for Health service. 54 // 55 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 56 type HealthClient interface { 57 // If the requested service is unknown, the call will fail with status 58 // NOT_FOUND. 59 Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc_go.CallOption) (*HealthCheckResponse, common.ErrorWithAttachment) 60 // Performs a watch for the serving status of the requested service. 61 // The server will immediately send back a message indicating the current 62 // serving status. It will then subsequently send a new message whenever 63 // the service's serving status changes. 64 // 65 // If the requested service is unknown when the call is received, the 66 // server will send a message setting the serving status to 67 // SERVICE_UNKNOWN but will *not* terminate the call. If at some 68 // future point, the serving status of the service becomes known, the 69 // server will send a new message with the service's serving status. 70 // 71 // If the call terminates with status UNIMPLEMENTED, then clients 72 // should assume this method is not supported and should not retry the 73 // call. If the call terminates with any other status (including OK), 74 // clients should retry the call with appropriate exponential backoff. 75 Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc_go.CallOption) (Health_WatchClient, error) 76 } 77 78 type healthClient struct { 79 cc *triple.TripleConn 80 } 81 82 type HealthClientImpl struct { 83 Check func(ctx context.Context, in *HealthCheckRequest) (*HealthCheckResponse, error) 84 Watch func(ctx context.Context, in *HealthCheckRequest) (Health_WatchClient, error) 85 } 86 87 func (c *HealthClientImpl) GetDubboStub(cc *triple.TripleConn) HealthClient { 88 return NewHealthClient(cc) 89 } 90 91 func (c *HealthClientImpl) XXX_InterfaceName() string { 92 return "dubbogo.health.v1.Health" 93 } 94 95 func NewHealthClient(cc *triple.TripleConn) HealthClient { 96 return &healthClient{cc} 97 } 98 99 func (c *healthClient) Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc_go.CallOption) (*HealthCheckResponse, common.ErrorWithAttachment) { 100 out := new(HealthCheckResponse) 101 interfaceKey := ctx.Value(constant.InterfaceKey).(string) 102 return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/Check", in, out) 103 } 104 105 func (c *healthClient) Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc_go.CallOption) (Health_WatchClient, error) { 106 interfaceKey := ctx.Value(constant.InterfaceKey).(string) 107 stream, err := c.cc.NewStream(ctx, "/"+interfaceKey+"/Watch", opts...) 108 if err != nil { 109 return nil, err 110 } 111 x := &healthWatchClient{stream} 112 if err := x.ClientStream.SendMsg(in); err != nil { 113 return nil, err 114 } 115 if err := x.ClientStream.CloseSend(); err != nil { 116 return nil, err 117 } 118 return x, nil 119 } 120 121 type Health_WatchClient interface { 122 Recv() (*HealthCheckResponse, error) 123 grpc_go.ClientStream 124 } 125 126 type healthWatchClient struct { 127 grpc_go.ClientStream 128 } 129 130 func (x *healthWatchClient) Recv() (*HealthCheckResponse, error) { 131 m := new(HealthCheckResponse) 132 if err := x.ClientStream.RecvMsg(m); err != nil { 133 return nil, err 134 } 135 return m, nil 136 } 137 138 // HealthServer is the server API for Health service. 139 // All implementations must embed UnimplementedHealthServer 140 // for forward compatibility 141 type HealthServer interface { 142 // If the requested service is unknown, the call will fail with status 143 // NOT_FOUND. 144 Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) 145 // Performs a watch for the serving status of the requested service. 146 // The server will immediately send back a message indicating the current 147 // serving status. It will then subsequently send a new message whenever 148 // the service's serving status changes. 149 // 150 // If the requested service is unknown when the call is received, the 151 // server will send a message setting the serving status to 152 // SERVICE_UNKNOWN but will *not* terminate the call. If at some 153 // future point, the serving status of the service becomes known, the 154 // server will send a new message with the service's serving status. 155 // 156 // If the call terminates with status UNIMPLEMENTED, then clients 157 // should assume this method is not supported and should not retry the 158 // call. If the call terminates with any other status (including OK), 159 // clients should retry the call with appropriate exponential backoff. 160 Watch(*HealthCheckRequest, Health_WatchServer) error 161 mustEmbedUnimplementedHealthServer() 162 } 163 164 // UnimplementedHealthServer must be embedded to have forward compatible implementations. 165 type UnimplementedHealthServer struct { 166 proxyImpl protocol.Invoker 167 } 168 169 func (UnimplementedHealthServer) Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) { 170 return nil, status.Errorf(codes.Unimplemented, "method Check not implemented") 171 } 172 func (UnimplementedHealthServer) Watch(*HealthCheckRequest, Health_WatchServer) error { 173 return status.Errorf(codes.Unimplemented, "method Watch not implemented") 174 } 175 func (s *UnimplementedHealthServer) XXX_SetProxyImpl(impl protocol.Invoker) { 176 s.proxyImpl = impl 177 } 178 179 func (s *UnimplementedHealthServer) XXX_GetProxyImpl() protocol.Invoker { 180 return s.proxyImpl 181 } 182 183 func (s *UnimplementedHealthServer) XXX_ServiceDesc() *grpc_go.ServiceDesc { 184 return &Health_ServiceDesc 185 } 186 func (s *UnimplementedHealthServer) XXX_InterfaceName() string { 187 return "dubbogo.health.v1.Health" 188 } 189 190 func (UnimplementedHealthServer) mustEmbedUnimplementedHealthServer() {} 191 192 // UnsafeHealthServer may be embedded to opt out of forward compatibility for this service. 193 // Use of this interface is not recommended, as added methods to HealthServer will 194 // result in compilation errors. 195 type UnsafeHealthServer interface { 196 mustEmbedUnimplementedHealthServer() 197 } 198 199 func RegisterHealthServer(s grpc_go.ServiceRegistrar, srv HealthServer) { 200 s.RegisterService(&Health_ServiceDesc, srv) 201 } 202 203 func _Health_Check_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { 204 in := new(HealthCheckRequest) 205 if err := dec(in); err != nil { 206 return nil, err 207 } 208 base := srv.(dubbo3.Dubbo3GrpcService) 209 args := []interface{}{} 210 args = append(args, in) 211 md, _ := metadata.FromIncomingContext(ctx) 212 invAttachment := make(map[string]interface{}, len(md)) 213 for k, v := range md { 214 invAttachment[k] = v 215 } 216 invo := invocation.NewRPCInvocation("Check", args, invAttachment) 217 if interceptor == nil { 218 result := base.XXX_GetProxyImpl().Invoke(ctx, invo) 219 return result, result.Error() 220 } 221 info := &grpc_go.UnaryServerInfo{ 222 Server: srv, 223 FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string), 224 } 225 handler := func(ctx context.Context, req interface{}) (interface{}, error) { 226 result := base.XXX_GetProxyImpl().Invoke(ctx, invo) 227 return result, result.Error() 228 } 229 return interceptor(ctx, in, info, handler) 230 } 231 232 func _Health_Watch_Handler(srv interface{}, stream grpc_go.ServerStream) error { 233 _, ok := srv.(dubbo3.Dubbo3GrpcService) 234 ctx := stream.Context() 235 md, _ := metadata.FromIncomingContext(ctx) 236 invAttachment := make(map[string]interface{}, len(md)) 237 for k, v := range md { 238 invAttachment[k] = v 239 } 240 stream.(grpc_go.CtxSetterStream).SetContext(context.WithValue(ctx, constant1.AttachmentKey, invAttachment)) 241 invo := invocation.NewRPCInvocation("Watch", nil, nil) 242 if !ok { 243 fmt.Println(invo) 244 return nil 245 } 246 m := new(HealthCheckRequest) 247 if err := stream.RecvMsg(m); err != nil { 248 return err 249 } 250 return srv.(HealthServer).Watch(m, &healthWatchServer{stream}) 251 } 252 253 type Health_WatchServer interface { 254 Send(*HealthCheckResponse) error 255 grpc_go.ServerStream 256 } 257 258 type healthWatchServer struct { 259 grpc_go.ServerStream 260 } 261 262 func (x *healthWatchServer) Send(m *HealthCheckResponse) error { 263 return x.ServerStream.SendMsg(m) 264 } 265 266 // Health_ServiceDesc is the grpc_go.ServiceDesc for Health service. 267 // It's only intended for direct use with grpc_go.RegisterService, 268 // and not to be introspected or modified (even as a copy) 269 var Health_ServiceDesc = grpc_go.ServiceDesc{ 270 ServiceName: "dubbogo.health.v1.Health", 271 HandlerType: (*HealthServer)(nil), 272 Methods: []grpc_go.MethodDesc{ 273 { 274 MethodName: "Check", 275 Handler: _Health_Check_Handler, 276 }, 277 }, 278 Streams: []grpc_go.StreamDesc{ 279 { 280 StreamName: "Watch", 281 Handler: _Health_Watch_Handler, 282 ServerStreams: true, 283 }, 284 }, 285 Metadata: "health.proto", 286 }