grpchealth

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

README

grpchealth

it is a package that implement grpc health probe v1

Example
    healthServer := grpchealth.NewServer("demo",
		health.WithChecksFunc(checkHealth),
		//health.WithRegularInterval(time.Minute),
	)

    func checksFunc() healthpb.HealthCheckResponse_ServingStatus {
	// TODO: check your service
	return healthpb.HealthCheckResponse_SERVING
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements client Health.

func NewClient

func NewClient(conn *grpc.ClientConn) *Client

NewClient return a new client

func (*Client) Check

Check return service's status

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server implements service Health.

func NewServer

func NewServer(service string, opts ...ServerOption) *Server

NewServer returns a health Server.

func (*Server) Check

Check implements `service Health`.

func (*Server) SetServingStatus

func (s *Server) SetServingStatus(servingStatus healthpb.HealthCheckResponse_ServingStatus)

SetServingStatus is called when need to reset the serving status of a service or insert a new service entry into the statusMap.

func (*Server) Watch

Watch implements `service Health`.

type ServerOption

type ServerOption func(*serverOptions)

ServerOption is server option

func WithChecksFunc

func WithChecksFunc(checksFunc func() healthpb.HealthCheckResponse_ServingStatus) ServerOption

WithChecksFunc set checks function

func WithRegularInterval

func WithRegularInterval(d time.Duration) ServerOption

WithRegularInterval set checking health interval

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL