| /* |
| * 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. |
| */ |
| |
| // Code generated by protoc-gen-go-triple. DO NOT EDIT. |
| // versions: |
| // - protoc-gen-go-triple v1.0.8 |
| // - protoc v3.20.1 |
| // source: protocol/dubbo3/health/triple_health_v1/health.proto |
| |
| package triple_health_v1 |
| |
| import ( |
| context "context" |
| fmt "fmt" |
| ) |
| |
| import ( |
| grpc_go "github.com/dubbogo/grpc-go" |
| codes "github.com/dubbogo/grpc-go/codes" |
| metadata "github.com/dubbogo/grpc-go/metadata" |
| status "github.com/dubbogo/grpc-go/status" |
| |
| common "github.com/dubbogo/triple/pkg/common" |
| constant "github.com/dubbogo/triple/pkg/common/constant" |
| triple "github.com/dubbogo/triple/pkg/triple" |
| ) |
| |
| import ( |
| constant1 "dubbo.apache.org/dubbo-go/v3/common/constant" |
| protocol "dubbo.apache.org/dubbo-go/v3/protocol" |
| dubbo3 "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3" |
| invocation "dubbo.apache.org/dubbo-go/v3/protocol/invocation" |
| ) |
| |
| // This is a compile-time assertion to ensure that this generated file |
| // is compatible with the grpc package it is being compiled against. |
| const _ = grpc_go.SupportPackageIsVersion7 |
| |
| // HealthClient is the client API for Health service. |
| // |
| // 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. |
| type HealthClient interface { |
| // If the requested service is unknown, the call will fail with status |
| // NOT_FOUND. |
| Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc_go.CallOption) (*HealthCheckResponse, common.ErrorWithAttachment) |
| // Performs a watch for the serving status of the requested service. |
| // The server will immediately send back a message indicating the current |
| // serving status. It will then subsequently send a new message whenever |
| // the service's serving status changes. |
| // |
| // If the requested service is unknown when the call is received, the |
| // server will send a message setting the serving status to |
| // SERVICE_UNKNOWN but will *not* terminate the call. If at some |
| // future point, the serving status of the service becomes known, the |
| // server will send a new message with the service's serving status. |
| // |
| // If the call terminates with status UNIMPLEMENTED, then clients |
| // should assume this method is not supported and should not retry the |
| // call. If the call terminates with any other status (including OK), |
| // clients should retry the call with appropriate exponential backoff. |
| Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc_go.CallOption) (Health_WatchClient, error) |
| } |
| |
| type healthClient struct { |
| cc *triple.TripleConn |
| } |
| |
| type HealthClientImpl struct { |
| Check func(ctx context.Context, in *HealthCheckRequest) (*HealthCheckResponse, error) |
| Watch func(ctx context.Context, in *HealthCheckRequest) (Health_WatchClient, error) |
| } |
| |
| func (c *HealthClientImpl) GetDubboStub(cc *triple.TripleConn) HealthClient { |
| return NewHealthClient(cc) |
| } |
| |
| func (c *HealthClientImpl) XXX_InterfaceName() string { |
| return "grpc.health.v1.Health" |
| } |
| |
| func NewHealthClient(cc *triple.TripleConn) HealthClient { |
| return &healthClient{cc} |
| } |
| |
| func (c *healthClient) Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc_go.CallOption) (*HealthCheckResponse, common.ErrorWithAttachment) { |
| out := new(HealthCheckResponse) |
| interfaceKey := ctx.Value(constant.InterfaceKey).(string) |
| return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/Check", in, out) |
| } |
| |
| func (c *healthClient) Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc_go.CallOption) (Health_WatchClient, error) { |
| interfaceKey := ctx.Value(constant.InterfaceKey).(string) |
| stream, err := c.cc.NewStream(ctx, "/"+interfaceKey+"/Watch", opts...) |
| if err != nil { |
| return nil, err |
| } |
| x := &healthWatchClient{stream} |
| if err := x.ClientStream.SendMsg(in); err != nil { |
| return nil, err |
| } |
| if err := x.ClientStream.CloseSend(); err != nil { |
| return nil, err |
| } |
| return x, nil |
| } |
| |
| type Health_WatchClient interface { |
| Recv() (*HealthCheckResponse, error) |
| grpc_go.ClientStream |
| } |
| |
| type healthWatchClient struct { |
| grpc_go.ClientStream |
| } |
| |
| func (x *healthWatchClient) Recv() (*HealthCheckResponse, error) { |
| m := new(HealthCheckResponse) |
| if err := x.ClientStream.RecvMsg(m); err != nil { |
| return nil, err |
| } |
| return m, nil |
| } |
| |
| // HealthServer is the server API for Health service. |
| // All implementations must embed UnimplementedHealthServer |
| // for forward compatibility |
| type HealthServer interface { |
| // If the requested service is unknown, the call will fail with status |
| // NOT_FOUND. |
| Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) |
| // Performs a watch for the serving status of the requested service. |
| // The server will immediately send back a message indicating the current |
| // serving status. It will then subsequently send a new message whenever |
| // the service's serving status changes. |
| // |
| // If the requested service is unknown when the call is received, the |
| // server will send a message setting the serving status to |
| // SERVICE_UNKNOWN but will *not* terminate the call. If at some |
| // future point, the serving status of the service becomes known, the |
| // server will send a new message with the service's serving status. |
| // |
| // If the call terminates with status UNIMPLEMENTED, then clients |
| // should assume this method is not supported and should not retry the |
| // call. If the call terminates with any other status (including OK), |
| // clients should retry the call with appropriate exponential backoff. |
| Watch(*HealthCheckRequest, Health_WatchServer) error |
| mustEmbedUnimplementedHealthServer() |
| } |
| |
| // UnimplementedHealthServer must be embedded to have forward compatible implementations. |
| type UnimplementedHealthServer struct { |
| proxyImpl protocol.Invoker |
| } |
| |
| func (UnimplementedHealthServer) Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) { |
| return nil, status.Errorf(codes.Unimplemented, "method Check not implemented") |
| } |
| func (UnimplementedHealthServer) Watch(*HealthCheckRequest, Health_WatchServer) error { |
| return status.Errorf(codes.Unimplemented, "method Watch not implemented") |
| } |
| func (s *UnimplementedHealthServer) XXX_SetProxyImpl(impl protocol.Invoker) { |
| s.proxyImpl = impl |
| } |
| |
| func (s *UnimplementedHealthServer) XXX_GetProxyImpl() protocol.Invoker { |
| return s.proxyImpl |
| } |
| |
| func (s *UnimplementedHealthServer) XXX_ServiceDesc() *grpc_go.ServiceDesc { |
| return &Health_ServiceDesc |
| } |
| func (s *UnimplementedHealthServer) XXX_InterfaceName() string { |
| return "grpc.health.v1.Health" |
| } |
| |
| func (UnimplementedHealthServer) mustEmbedUnimplementedHealthServer() {} |
| |
| // UnsafeHealthServer may be embedded to opt out of forward compatibility for this service. |
| // Use of this interface is not recommended, as added methods to HealthServer will |
| // result in compilation errors. |
| type UnsafeHealthServer interface { |
| mustEmbedUnimplementedHealthServer() |
| } |
| |
| func RegisterHealthServer(s grpc_go.ServiceRegistrar, srv HealthServer) { |
| s.RegisterService(&Health_ServiceDesc, srv) |
| } |
| |
| func _Health_Check_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { |
| in := new(HealthCheckRequest) |
| if err := dec(in); err != nil { |
| return nil, err |
| } |
| base := srv.(dubbo3.Dubbo3GrpcService) |
| args := []interface{}{} |
| args = append(args, in) |
| md, _ := metadata.FromIncomingContext(ctx) |
| invAttachment := make(map[string]interface{}, len(md)) |
| for k, v := range md { |
| invAttachment[k] = v |
| } |
| invo := invocation.NewRPCInvocation("Check", args, invAttachment) |
| if interceptor == nil { |
| result := base.XXX_GetProxyImpl().Invoke(ctx, invo) |
| return result, result.Error() |
| } |
| info := &grpc_go.UnaryServerInfo{ |
| Server: srv, |
| FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string), |
| } |
| handler := func(ctx context.Context, req interface{}) (interface{}, error) { |
| result := base.XXX_GetProxyImpl().Invoke(ctx, invo) |
| return result, result.Error() |
| } |
| return interceptor(ctx, in, info, handler) |
| } |
| |
| func _Health_Watch_Handler(srv interface{}, stream grpc_go.ServerStream) error { |
| _, ok := srv.(dubbo3.Dubbo3GrpcService) |
| ctx := stream.Context() |
| md, _ := metadata.FromIncomingContext(ctx) |
| invAttachment := make(map[string]interface{}, len(md)) |
| for k, v := range md { |
| invAttachment[k] = v |
| } |
| stream.(grpc_go.CtxSetterStream).SetContext(context.WithValue(ctx, constant1.AttachmentKey, invAttachment)) |
| invo := invocation.NewRPCInvocation("Watch", nil, nil) |
| if !ok { |
| fmt.Println(invo) |
| return nil |
| } |
| m := new(HealthCheckRequest) |
| if err := stream.RecvMsg(m); err != nil { |
| return err |
| } |
| return srv.(HealthServer).Watch(m, &healthWatchServer{stream}) |
| } |
| |
| type Health_WatchServer interface { |
| Send(*HealthCheckResponse) error |
| grpc_go.ServerStream |
| } |
| |
| type healthWatchServer struct { |
| grpc_go.ServerStream |
| } |
| |
| func (x *healthWatchServer) Send(m *HealthCheckResponse) error { |
| return x.ServerStream.SendMsg(m) |
| } |
| |
| // Health_ServiceDesc is the grpc_go.ServiceDesc for Health service. |
| // It's only intended for direct use with grpc_go.RegisterService, |
| // and not to be introspected or modified (even as a copy) |
| var Health_ServiceDesc = grpc_go.ServiceDesc{ |
| ServiceName: "grpc.health.v1.Health", |
| HandlerType: (*HealthServer)(nil), |
| Methods: []grpc_go.MethodDesc{ |
| { |
| MethodName: "Check", |
| Handler: _Health_Check_Handler, |
| }, |
| }, |
| Streams: []grpc_go.StreamDesc{ |
| { |
| StreamName: "Watch", |
| Handler: _Health_Watch_Handler, |
| ServerStreams: true, |
| }, |
| }, |
| Metadata: "protocol/dubbo3/health/triple_health_v1/health.proto", |
| } |