Documentation
¶
Index ¶
- Constants
- func NewHealthHandler(svc HealthHandler, opts ...connect.HandlerOption) (string, http.Handler)
- type HealthClient
- type HealthHandler
- type UnimplementedHealthHandler
- func (UnimplementedHealthHandler) Check(context.Context, *connect.Request[v1.HealthCheckRequest]) (*connect.Response[v1.HealthCheckResponse], error)
- func (UnimplementedHealthHandler) List(context.Context, *connect.Request[v1.HealthListRequest]) (*connect.Response[v1.HealthListResponse], error)
- func (UnimplementedHealthHandler) Watch(context.Context, *connect.Request[v1.HealthCheckRequest], ...) error
Constants ¶
const ( // HealthCheckProcedure is the fully-qualified name of the Health's Check RPC. HealthCheckProcedure = "/grpc.health.v1.Health/Check" // HealthListProcedure is the fully-qualified name of the Health's List RPC. HealthListProcedure = "/grpc.health.v1.Health/List" // HealthWatchProcedure is the fully-qualified name of the Health's Watch RPC. HealthWatchProcedure = "/grpc.health.v1.Health/Watch" )
These constants are the fully-qualified names of the RPCs defined in this package. They're exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
Note that these are different from the fully-qualified method names used by google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to reflection-formatted method names, remove the leading slash and convert the remaining slash to a period.
const (
// HealthName is the fully-qualified name of the Health service.
HealthName = "grpc.health.v1.Health"
)
Variables ¶
This section is empty.
Functions ¶
func NewHealthHandler ¶
func NewHealthHandler(svc HealthHandler, opts ...connect.HandlerOption) (string, http.Handler)
NewHealthHandler builds an HTTP handler from the service implementation. It returns the path on which to mount the handler and the handler itself.
By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf and JSON codecs. They also support gzip compression.
Types ¶
type HealthClient ¶
type HealthClient interface {
// Check gets the health of the specified service. If the requested service
// is unknown, the call will fail with status NOT_FOUND. If the caller does
// not specify a service name, the server should respond with its overall
// health status.
//
// Clients should set a deadline when calling Check, and can declare the
// server unhealthy if they do not receive a timely response.
Check(context.Context, *connect.Request[v1.HealthCheckRequest]) (*connect.Response[v1.HealthCheckResponse], error)
// List provides a non-atomic snapshot of the health of all the available
// services.
//
// The server may respond with a RESOURCE_EXHAUSTED error if too many services
// exist.
//
// Clients should set a deadline when calling List, and can declare the server
// unhealthy if they do not receive a timely response.
//
// Clients should keep in mind that the list of health services exposed by an
// application can change over the lifetime of the process.
List(context.Context, *connect.Request[v1.HealthListRequest]) (*connect.Response[v1.HealthListResponse], 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(context.Context, *connect.Request[v1.HealthCheckRequest]) (*connect.ServerStreamForClient[v1.HealthCheckResponse], error)
}
HealthClient is a client for the grpc.health.v1.Health service.
func NewHealthClient ¶
func NewHealthClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) HealthClient
NewHealthClient constructs a client for the grpc.health.v1.Health service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or connect.WithGRPCWeb() options.
The URL supplied here should be the base URL for the Connect or gRPC server (for example, http://api.acme.com or https://acme.com/grpc).
type HealthHandler ¶
type HealthHandler interface {
// Check gets the health of the specified service. If the requested service
// is unknown, the call will fail with status NOT_FOUND. If the caller does
// not specify a service name, the server should respond with its overall
// health status.
//
// Clients should set a deadline when calling Check, and can declare the
// server unhealthy if they do not receive a timely response.
Check(context.Context, *connect.Request[v1.HealthCheckRequest]) (*connect.Response[v1.HealthCheckResponse], error)
// List provides a non-atomic snapshot of the health of all the available
// services.
//
// The server may respond with a RESOURCE_EXHAUSTED error if too many services
// exist.
//
// Clients should set a deadline when calling List, and can declare the server
// unhealthy if they do not receive a timely response.
//
// Clients should keep in mind that the list of health services exposed by an
// application can change over the lifetime of the process.
List(context.Context, *connect.Request[v1.HealthListRequest]) (*connect.Response[v1.HealthListResponse], 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(context.Context, *connect.Request[v1.HealthCheckRequest], *connect.ServerStream[v1.HealthCheckResponse]) error
}
HealthHandler is an implementation of the grpc.health.v1.Health service.
type UnimplementedHealthHandler ¶
type UnimplementedHealthHandler struct{}
UnimplementedHealthHandler returns CodeUnimplemented from all methods.
func (UnimplementedHealthHandler) Check ¶
func (UnimplementedHealthHandler) Check(context.Context, *connect.Request[v1.HealthCheckRequest]) (*connect.Response[v1.HealthCheckResponse], error)
func (UnimplementedHealthHandler) List ¶
func (UnimplementedHealthHandler) List(context.Context, *connect.Request[v1.HealthListRequest]) (*connect.Response[v1.HealthListResponse], error)
func (UnimplementedHealthHandler) Watch ¶
func (UnimplementedHealthHandler) Watch(context.Context, *connect.Request[v1.HealthCheckRequest], *connect.ServerStream[v1.HealthCheckResponse]) error
Source Files
¶
- health.connect.go