health

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Startup   string = "Startup"
	Readiness string = "Readiness"
	Liveness  string = "Liveness"
)
View Source
const (
	IPAMSvc              string = "IPAM"
	IPAMCliSvc           string = "IPAMCli"
	NSPCliSvc            string = "NSPCli"
	EgressSvc            string = "Egress"
	NSMEndpointSvc       string = "NSMEndpoint"
	TargetRegistryCliSvc string = "TargetRegistryCli"
	StreamSvc            string = "Stream"
	FlowSvc              string = "Flow"
)
View Source
const (
	DefaultURL string = "unix:///tmp/health.sock"
)

Variables

View Source
var IPAMReadinessServices []string = []string{NSPCliSvc, IPAMSvc}
View Source
var ProxyReadinessServices []string = []string{IPAMCliSvc, NSPCliSvc, NSMEndpointSvc, EgressSvc}

Functions

func CreateChecker

func CreateChecker(ctx context.Context, options ...Option) context.Context

CreateChecker - Wraps NewChecker() and saves Checker into context, also starts Checker in a goroutine TODO: revisit if it's really needed to fail the program on error

func RegisterReadinesSubservices

func RegisterReadinesSubservices(ctx context.Context, services ...string) error

RegisterReadinesSubservices - Wraps Checker.RegisterServices() by fetching the health server (i.e. Checker) from context

func SetServingStatus

func SetServingStatus(ctx context.Context, service string, serving bool)

SetServingStatus - Wraps Checker.SetServingStatus() by fetching the health server (i.e. Checker) from context

func WithHealthServer

func WithHealthServer(parent context.Context, server *Checker) context.Context

withHealthServer - Store Health Server (Checker) in Context

Types

type Checker

type Checker struct {
	grpc_health_v1.HealthServer
	HealthServerStatusModifier
	// contains filtered or unexported fields
}

func HealthServer

func HealthServer(ctx context.Context) *Checker

Server - Returns Health Server (Checker) from the context.Context

func NewChecker

func NewChecker(options ...Option) (*Checker, error)

NewChecker - Creates gRPC health server

func (*Checker) Check

Check - Re-implements Check() function of grpc_health_v1.HealthServer interface in order to log if a probe service is about to fail.

func (*Checker) RegisterServices

func (c *Checker) RegisterServices(probeSvc string, services ...string)

RegisterServices - Registers subservices for a probe service whose serving status will be deterimined by the serving status of the subservices. Note: currently a subservice can only belong to one probe service

func (*Checker) SetServingStatus

func (c *Checker) SetServingStatus(service string, servingStatus grpc_health_v1.HealthCheckResponse_ServingStatus)

Re-implements SetServingStatus function in order to evaluate probe service status in case a related subservice is subject to the call

func (*Checker) Start

func (c *Checker) Start() error

Start - Starts gRPC health server

type HealthServerStatusModifier

type HealthServerStatusModifier interface {
	SetServingStatus(service string, servingStatus grpc_health_v1.HealthCheckResponse_ServingStatus)
	Shutdown()
}

type Option

type Option func(o *checkerOptions)

Option is an option pattern for NewChecker

func WithCtx

func WithCtx(ctx context.Context) Option

WithCtx sets context

func WithURL

func WithURL(u *url.URL) Option

WithURL sets url

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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