...

Source file src/google.golang.org/grpc/health/grpc_health_v1/health_grpc.pb.go

Documentation: google.golang.org/grpc/health/grpc_health_v1

     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.3.0
    21  // - protoc             v4.25.2
    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.62.0 or later.
    36  const _ = grpc.SupportPackageIsVersion8
    37  
    38  const (
    39  	Health_Check_FullMethodName = "/grpc.health.v1.Health/Check"
    40  	Health_Watch_FullMethodName = "/grpc.health.v1.Health/Watch"
    41  )
    42  
    43  // HealthClient is the client API for Health service.
    44  //
    45  // 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.
    46  type HealthClient interface {
    47  	// Check gets the health of the specified service. If the requested service
    48  	// is unknown, the call will fail with status NOT_FOUND. If the caller does
    49  	// not specify a service name, the server should respond with its overall
    50  	// health status.
    51  	//
    52  	// Clients should set a deadline when calling Check, and can declare the
    53  	// server unhealthy if they do not receive a timely response.
    54  	//
    55  	// Check implementations should be idempotent and side effect free.
    56  	Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error)
    57  	// Performs a watch for the serving status of the requested service.
    58  	// The server will immediately send back a message indicating the current
    59  	// serving status.  It will then subsequently send a new message whenever
    60  	// the service's serving status changes.
    61  	//
    62  	// If the requested service is unknown when the call is received, the
    63  	// server will send a message setting the serving status to
    64  	// SERVICE_UNKNOWN but will *not* terminate the call.  If at some
    65  	// future point, the serving status of the service becomes known, the
    66  	// server will send a new message with the service's serving status.
    67  	//
    68  	// If the call terminates with status UNIMPLEMENTED, then clients
    69  	// should assume this method is not supported and should not retry the
    70  	// call.  If the call terminates with any other status (including OK),
    71  	// clients should retry the call with appropriate exponential backoff.
    72  	Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (Health_WatchClient, error)
    73  }
    74  
    75  type healthClient struct {
    76  	cc grpc.ClientConnInterface
    77  }
    78  
    79  func NewHealthClient(cc grpc.ClientConnInterface) HealthClient {
    80  	return &healthClient{cc}
    81  }
    82  
    83  func (c *healthClient) Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error) {
    84  	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
    85  	out := new(HealthCheckResponse)
    86  	err := c.cc.Invoke(ctx, Health_Check_FullMethodName, in, out, cOpts...)
    87  	if err != nil {
    88  		return nil, err
    89  	}
    90  	return out, nil
    91  }
    92  
    93  func (c *healthClient) Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (Health_WatchClient, error) {
    94  	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
    95  	stream, err := c.cc.NewStream(ctx, &Health_ServiceDesc.Streams[0], Health_Watch_FullMethodName, cOpts...)
    96  	if err != nil {
    97  		return nil, err
    98  	}
    99  	x := &healthWatchClient{ClientStream: stream}
   100  	if err := x.ClientStream.SendMsg(in); err != nil {
   101  		return nil, err
   102  	}
   103  	if err := x.ClientStream.CloseSend(); err != nil {
   104  		return nil, err
   105  	}
   106  	return x, nil
   107  }
   108  
   109  type Health_WatchClient interface {
   110  	Recv() (*HealthCheckResponse, error)
   111  	grpc.ClientStream
   112  }
   113  
   114  type healthWatchClient struct {
   115  	grpc.ClientStream
   116  }
   117  
   118  func (x *healthWatchClient) Recv() (*HealthCheckResponse, error) {
   119  	m := new(HealthCheckResponse)
   120  	if err := x.ClientStream.RecvMsg(m); err != nil {
   121  		return nil, err
   122  	}
   123  	return m, nil
   124  }
   125  
   126  // HealthServer is the server API for Health service.
   127  // All implementations should embed UnimplementedHealthServer
   128  // for forward compatibility
   129  type HealthServer interface {
   130  	// Check gets the health of the specified service. If the requested service
   131  	// is unknown, the call will fail with status NOT_FOUND. If the caller does
   132  	// not specify a service name, the server should respond with its overall
   133  	// health status.
   134  	//
   135  	// Clients should set a deadline when calling Check, and can declare the
   136  	// server unhealthy if they do not receive a timely response.
   137  	//
   138  	// Check implementations should be idempotent and side effect free.
   139  	Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error)
   140  	// Performs a watch for the serving status of the requested service.
   141  	// The server will immediately send back a message indicating the current
   142  	// serving status.  It will then subsequently send a new message whenever
   143  	// the service's serving status changes.
   144  	//
   145  	// If the requested service is unknown when the call is received, the
   146  	// server will send a message setting the serving status to
   147  	// SERVICE_UNKNOWN but will *not* terminate the call.  If at some
   148  	// future point, the serving status of the service becomes known, the
   149  	// server will send a new message with the service's serving status.
   150  	//
   151  	// If the call terminates with status UNIMPLEMENTED, then clients
   152  	// should assume this method is not supported and should not retry the
   153  	// call.  If the call terminates with any other status (including OK),
   154  	// clients should retry the call with appropriate exponential backoff.
   155  	Watch(*HealthCheckRequest, Health_WatchServer) error
   156  }
   157  
   158  // UnimplementedHealthServer should be embedded to have forward compatible implementations.
   159  type UnimplementedHealthServer struct {
   160  }
   161  
   162  func (UnimplementedHealthServer) Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) {
   163  	return nil, status.Errorf(codes.Unimplemented, "method Check not implemented")
   164  }
   165  func (UnimplementedHealthServer) Watch(*HealthCheckRequest, Health_WatchServer) error {
   166  	return status.Errorf(codes.Unimplemented, "method Watch not implemented")
   167  }
   168  
   169  // UnsafeHealthServer may be embedded to opt out of forward compatibility for this service.
   170  // Use of this interface is not recommended, as added methods to HealthServer will
   171  // result in compilation errors.
   172  type UnsafeHealthServer interface {
   173  	mustEmbedUnimplementedHealthServer()
   174  }
   175  
   176  func RegisterHealthServer(s grpc.ServiceRegistrar, srv HealthServer) {
   177  	s.RegisterService(&Health_ServiceDesc, srv)
   178  }
   179  
   180  func _Health_Check_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
   181  	in := new(HealthCheckRequest)
   182  	if err := dec(in); err != nil {
   183  		return nil, err
   184  	}
   185  	if interceptor == nil {
   186  		return srv.(HealthServer).Check(ctx, in)
   187  	}
   188  	info := &grpc.UnaryServerInfo{
   189  		Server:     srv,
   190  		FullMethod: Health_Check_FullMethodName,
   191  	}
   192  	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
   193  		return srv.(HealthServer).Check(ctx, req.(*HealthCheckRequest))
   194  	}
   195  	return interceptor(ctx, in, info, handler)
   196  }
   197  
   198  func _Health_Watch_Handler(srv interface{}, stream grpc.ServerStream) error {
   199  	m := new(HealthCheckRequest)
   200  	if err := stream.RecvMsg(m); err != nil {
   201  		return err
   202  	}
   203  	return srv.(HealthServer).Watch(m, &healthWatchServer{ServerStream: stream})
   204  }
   205  
   206  type Health_WatchServer interface {
   207  	Send(*HealthCheckResponse) error
   208  	grpc.ServerStream
   209  }
   210  
   211  type healthWatchServer struct {
   212  	grpc.ServerStream
   213  }
   214  
   215  func (x *healthWatchServer) Send(m *HealthCheckResponse) error {
   216  	return x.ServerStream.SendMsg(m)
   217  }
   218  
   219  // Health_ServiceDesc is the grpc.ServiceDesc for Health service.
   220  // It's only intended for direct use with grpc.RegisterService,
   221  // and not to be introspected or modified (even as a copy)
   222  var Health_ServiceDesc = grpc.ServiceDesc{
   223  	ServiceName: "grpc.health.v1.Health",
   224  	HandlerType: (*HealthServer)(nil),
   225  	Methods: []grpc.MethodDesc{
   226  		{
   227  			MethodName: "Check",
   228  			Handler:    _Health_Check_Handler,
   229  		},
   230  	},
   231  	Streams: []grpc.StreamDesc{
   232  		{
   233  			StreamName:    "Watch",
   234  			Handler:       _Health_Watch_Handler,
   235  			ServerStreams: true,
   236  		},
   237  	},
   238  	Metadata: "grpc/health/v1/health.proto",
   239  }
   240  

View as plain text