Documentation ¶
Index ¶
Constants ¶
const ( // DefaultInterval defines how often health check will run. // If DefaultTimeout > DefaultInterval, the next health check will be // dropped because of unfinished health check. DefaultInterval = 5 * time.Second // DefaultTimeout defines how long health check will run. // If the check function cannot be finished in time, a timeout error will be returned. DefaultTimeout = time.Second )
const ( StateUnknown State = 0 StateHealthy = 1 StateUnhealthy = 2 )
Variables ¶
This section is empty.
Functions ¶
func RegisterHandlerClient ¶
func RegisterServer ¶
func RegisterServer(s grpc.ServiceRegistrar, srv Server)
Types ¶
type CheckFunc ¶
CheckFunc is function which returns an error. It's an abstract definition of checking process. A customized checking process should be a CheckFunc.
Any panic in CheckFunc will cause process exit with error.
type Checker ¶
type Checker interface { // HealthCheck checks service health status HealthCheck(ctx context.Context) error }
Checker is an interface that implemented healtch check callback for health check runner.
type Reporter ¶
type Reporter interface { // LastStatus gets last health status LastStatus() Status // StatusReportChan returns health status report channel // There is only one channel for each reporter instance // The message in channel should be consumed immediately, otherwise the message will be dropped StatusReportChan() chan Status }
type RunOption ¶
type RunOption func(*runOptions)
RunOption is used by a health runner. A runner will apply these options when running the health check.
func WithCheckInterval ¶
WithCheckInterval sets the period of health check interval.
func WithCheckTimeout ¶
WithCheckTimeout sets the timeout of health check.
func WithPanicOnError ¶
WithPanicOnError indicates if we need to panic and crash the process when there is any error during health check.
If there is no error during health check, this option doesn't have any affect.
type Runner ¶
type Server ¶
type Server = grpc_health_v1.HealthServer