health

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 12 Imported by: 10

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"
	StreamSvc      string = "Stream"
	FlowSvc        string = "Flow"
	NSPSvc         string = "NSP"
	AmbassadorSvc  string = "Ambassador"
)
View Source
const (
	DefaultURL string = "unix:///tmp/health.sock"
)

Variables

View Source
var FEReadinessServices []string = []string{NSPCliSvc, EgressSvc}
View Source
var IPAMLivenessServices []string = []string{IPAMSvc}
View Source
var IPAMReadinessServices []string = []string{NSPCliSvc}
View Source
var LBLivenessServices []string = []string{NSMEndpointSvc}
View Source
var NSPLivenessServices []string = []string{NSPSvc}
View Source
var ProxyLivenessServices []string = []string{NSMEndpointSvc}
View Source
var ProxyReadinessServices []string = []string{IPAMCliSvc, NSPCliSvc, NSMEndpointSvc, EgressSvc}
View Source
var TAPALivenessServices []string = []string{AmbassadorSvc}

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 RegisterLivenessSubservices added in v1.0.13

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

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

func RegisterReadinessSubservices added in v1.0.13

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

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

func RegisterStartupSubservices added in v1.0.13

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

RegisterStartupSubservices - 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. Notes:

  • A subservice can be part of multiple probe services
  • No check for duplicate registration (e.g. services previously registered for the same probe service are not removed)

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