google.golang.org/grpc@v1.72.2/health/grpc_health_v1/health_grpc.pb.go (about)

     1  // Copyright 2015 The gRPC Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // The canonical version of this proto can be found at
    16  // https://github.com/grpc/grpc-proto/blob/master/grpc/health/v1/health.proto
    17  
    18  // Code generated by protoc-gen-go-grpc. DO NOT EDIT.
    19  // versions:
    20  // - protoc-gen-go-grpc v1.5.1
    21  // - protoc             v5.27.1
    22  // source: grpc/health/v1/health.proto
    23  
    24  package grpc_health_v1
    25  
    26  import (
    27  	context "context"
    28  	grpc "google.golang.org/grpc"
    29  	codes "google.golang.org/grpc/codes"
    30  	status "google.golang.org/grpc/status"
    31  )
    32  
    33  // This is a compile-time assertion to ensure that this generated file
    34  // is compatible with the grpc package it is being compiled against.
    35  // Requires gRPC-Go v1.64.0 or later.
    36  const _ = grpc.SupportPackageIsVersion9
    37  
    38  const (
    39  	Health_Check_FullMethodName = "/grpc.health.v1.Health/Check"
    40  	Health_List_FullMethodName  = "/grpc.health.v1.Health/List"
    41  	Health_Watch_FullMethodName = "/grpc.health.v1.Health/Watch"
    42  )
    43  
    44  // HealthClient is the client API for Health service.
    45  //
    46  // 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.
    47  //
    48  // Health is gRPC's mechanism for checking whether a server is able to handle
    49  // RPCs. Its semantics are documented in
    50  // https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
    51  type HealthClient interface {
    52  	// Check gets the health of the specified service. If the requested service
    53  	// is unknown, the call will fail with status NOT_FOUND. If the caller does
    54  	// not specify a service name, the server should respond with its overall
    55  	// health status.
    56  	//
    57  	// Clients should set a deadline when calling Check, and can declare the
    58  	// server unhealthy if they do not receive a timely response.
    59  	Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error)
    60  	// List provides a non-atomic snapshot of the health of all the available
    61  	// services.
    62  	//
    63  	// The server may respond with a RESOURCE_EXHAUSTED error if too many services
    64  	// exist.
    65  	//
    66  	// Clients should set a deadline when calling List, and can declare the server
    67  	// unhealthy if they do not receive a timely response.
    68  	//
    69  	// Clients should keep in mind that the list of health services exposed by an
    70  	// application can change over the lifetime of the process.
    71  	List(ctx context.Context, in *HealthListRequest, opts ...grpc.CallOption) (*HealthListResponse, error)
    72  	// Performs a watch for the serving status of the requested service.
    73  	// The server will immediately send back a message indicating the current
    74  	// serving status.  It will then subsequently send a new message whenever
    75  	// the service's serving status changes.
    76  	//
    77  	// If the requested service is unknown when the call is received, the
    78  	// server will send a message setting the serving status to
    79  	// SERVICE_UNKNOWN but will *not* terminate the call.  If at some
    80  	// future point, the serving status of the service becomes known, the
    81  	// server will send a new message with the service's serving status.
    82  	//
    83  	// If the call terminates with status UNIMPLEMENTED, then clients
    84  	// should assume this method is not supported and should not retry the
    85  	// call.  If the call terminates with any other status (including OK),
    86  	// clients should retry the call with appropriate exponential backoff.
    87  	Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[HealthCheckResponse], error)
    88  }
    89  
    90  type healthClient struct {
    91  	cc grpc.ClientConnInterface
    92  }
    93  
    94  func NewHealthClient(cc grpc.ClientConnInterface) HealthClient {
    95  	return &healthClient{cc}
    96  }
    97  
    98  func (c *healthClient) Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error) {
    99  	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
   100  	out := new(HealthCheckResponse)
   101  	err := c.cc.Invoke(ctx, Health_Check_FullMethodName, in, out, cOpts...)
   102  	if err != nil {
   103  		return nil, err
   104  	}
   105  	return out, nil
   106  }
   107  
   108  func (c *healthClient) List(ctx context.Context, in *HealthListRequest, opts ...grpc.CallOption) (*HealthListResponse, error) {
   109  	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
   110  	out := new(HealthListResponse)
   111  	err := c.cc.Invoke(ctx, Health_List_FullMethodName, in, out, cOpts...)
   112  	if err != nil {
   113  		return nil, err
   114  	}
   115  	return out, nil
   116  }
   117  
   118  func (c *healthClient) Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[HealthCheckResponse], error) {
   119  	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
   120  	stream, err := c.cc.NewStream(ctx, &Health_ServiceDesc.Streams[0], Health_Watch_FullMethodName, cOpts...)
   121  	if err != nil {
   122  		return nil, err
   123  	}
   124  	x := &grpc.GenericClientStream[HealthCheckRequest, HealthCheckResponse]{ClientStream: stream}
   125  	if err := x.ClientStream.SendMsg(in); err != nil {
   126  		return nil, err
   127  	}
   128  	if err := x.ClientStream.CloseSend(); err != nil {
   129  		return nil, err
   130  	}
   131  	return x, nil
   132  }
   133  
   134  // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
   135  type Health_WatchClient = grpc.ServerStreamingClient[HealthCheckResponse]
   136  
   137  // HealthServer is the server API for Health service.
   138  // All implementations should embed UnimplementedHealthServer
   139  // for forward compatibility.
   140  //
   141  // Health is gRPC's mechanism for checking whether a server is able to handle
   142  // RPCs. Its semantics are documented in
   143  // https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
   144  type HealthServer interface {
   145  	// Check gets the health of the specified service. If the requested service
   146  	// is unknown, the call will fail with status NOT_FOUND. If the caller does
   147  	// not specify a service name, the server should respond with its overall
   148  	// health status.
   149  	//
   150  	// Clients should set a deadline when calling Check, and can declare the
   151  	// server unhealthy if they do not receive a timely response.
   152  	Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error)
   153  	// List provides a non-atomic snapshot of the health of all the available
   154  	// services.
   155  	//
   156  	// The server may respond with a RESOURCE_EXHAUSTED error if too many services
   157  	// exist.
   158  	//
   159  	// Clients should set a deadline when calling List, and can declare the server
   160  	// unhealthy if they do not receive a timely response.
   161  	//
   162  	// Clients should keep in mind that the list of health services exposed by an
   163  	// application can change over the lifetime of the process.
   164  	List(context.Context, *HealthListRequest) (*HealthListResponse, error)
   165  	// Performs a watch for the serving status of the requested service.
   166  	// The server will immediately send back a message indicating the current
   167  	// serving status.  It will then subsequently send a new message whenever
   168  	// the service's serving status changes.
   169  	//
   170  	// If the requested service is unknown when the call is received, the
   171  	// server will send a message setting the serving status to
   172  	// SERVICE_UNKNOWN but will *not* terminate the call.  If at some
   173  	// future point, the serving status of the service becomes known, the
   174  	// server will send a new message with the service's serving status.
   175  	//
   176  	// If the call terminates with status UNIMPLEMENTED, then clients
   177  	// should assume this method is not supported and should not retry the
   178  	// call.  If the call terminates with any other status (including OK),
   179  	// clients should retry the call with appropriate exponential backoff.
   180  	Watch(*HealthCheckRequest, grpc.ServerStreamingServer[HealthCheckResponse]) error
   181  }
   182  
   183  // UnimplementedHealthServer should be embedded to have
   184  // forward compatible implementations.
   185  //
   186  // NOTE: this should be embedded by value instead of pointer to avoid a nil
   187  // pointer dereference when methods are called.
   188  type UnimplementedHealthServer struct{}
   189  
   190  func (UnimplementedHealthServer) Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) {
   191  	return nil, status.Errorf(codes.Unimplemented, "method Check not implemented")
   192  }
   193  func (UnimplementedHealthServer) List(context.Context, *HealthListRequest) (*HealthListResponse, error) {
   194  	return nil, status.Errorf(codes.Unimplemented, "method List not implemented")
   195  }
   196  func (UnimplementedHealthServer) Watch(*HealthCheckRequest, grpc.ServerStreamingServer[HealthCheckResponse]) error {
   197  	return status.Errorf(codes.Unimplemented, "method Watch not implemented")
   198  }
   199  func (UnimplementedHealthServer) testEmbeddedByValue() {}
   200  
   201  // UnsafeHealthServer may be embedded to opt out of forward compatibility for this service.
   202  // Use of this interface is not recommended, as added methods to HealthServer will
   203  // result in compilation errors.
   204  type UnsafeHealthServer interface {
   205  	mustEmbedUnimplementedHealthServer()
   206  }
   207  
   208  func RegisterHealthServer(s grpc.ServiceRegistrar, srv HealthServer) {
   209  	// If the following call panics, it indicates UnimplementedHealthServer was
   210  	// embedded by pointer and is nil.  This will cause panics if an
   211  	// unimplemented method is ever invoked, so we test this at initialization
   212  	// time to prevent it from happening at runtime later due to I/O.
   213  	if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
   214  		t.testEmbeddedByValue()
   215  	}
   216  	s.RegisterService(&Health_ServiceDesc, srv)
   217  }
   218  
   219  func _Health_Check_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
   220  	in := new(HealthCheckRequest)
   221  	if err := dec(in); err != nil {
   222  		return nil, err
   223  	}
   224  	if interceptor == nil {
   225  		return srv.(HealthServer).Check(ctx, in)
   226  	}
   227  	info := &grpc.UnaryServerInfo{
   228  		Server:     srv,
   229  		FullMethod: Health_Check_FullMethodName,
   230  	}
   231  	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
   232  		return srv.(HealthServer).Check(ctx, req.(*HealthCheckRequest))
   233  	}
   234  	return interceptor(ctx, in, info, handler)
   235  }
   236  
   237  func _Health_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
   238  	in := new(HealthListRequest)
   239  	if err := dec(in); err != nil {
   240  		return nil, err
   241  	}
   242  	if interceptor == nil {
   243  		return srv.(HealthServer).List(ctx, in)
   244  	}
   245  	info := &grpc.UnaryServerInfo{
   246  		Server:     srv,
   247  		FullMethod: Health_List_FullMethodName,
   248  	}
   249  	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
   250  		return srv.(HealthServer).List(ctx, req.(*HealthListRequest))
   251  	}
   252  	return interceptor(ctx, in, info, handler)
   253  }
   254  
   255  func _Health_Watch_Handler(srv interface{}, stream grpc.ServerStream) error {
   256  	m := new(HealthCheckRequest)
   257  	if err := stream.RecvMsg(m); err != nil {
   258  		return err
   259  	}
   260  	return srv.(HealthServer).Watch(m, &grpc.GenericServerStream[HealthCheckRequest, HealthCheckResponse]{ServerStream: stream})
   261  }
   262  
   263  // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
   264  type Health_WatchServer = grpc.ServerStreamingServer[HealthCheckResponse]
   265  
   266  // Health_ServiceDesc is the grpc.ServiceDesc for Health service.
   267  // It's only intended for direct use with grpc.RegisterService,
   268  // and not to be introspected or modified (even as a copy)
   269  var Health_ServiceDesc = grpc.ServiceDesc{
   270  	ServiceName: "grpc.health.v1.Health",
   271  	HandlerType: (*HealthServer)(nil),
   272  	Methods: []grpc.MethodDesc{
   273  		{
   274  			MethodName: "Check",
   275  			Handler:    _Health_Check_Handler,
   276  		},
   277  		{
   278  			MethodName: "List",
   279  			Handler:    _Health_List_Handler,
   280  		},
   281  	},
   282  	Streams: []grpc.StreamDesc{
   283  		{
   284  			StreamName:    "Watch",
   285  			Handler:       _Health_Watch_Handler,
   286  			ServerStreams: true,
   287  		},
   288  	},
   289  	Metadata: "grpc/health/v1/health.proto",
   290  }