health

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: BSD-3-Clause Imports: 5 Imported by: 0

README

Health

This module provides a health http endpoint (/health) that can be controlled by the use of a health.Service.

Initialization

app := fx.New(
	env.Module,
	logrus.Module,
	metrics.Module,
	fiber.Module,
	health.Module,
	func(service *health.ServiceHealth) {
		// use service here
	},
)
app.Run()

Service functions

  • IsHealthy checks a list of components if they are healthy. Returns false as soon as one of those components is unhealthy. If no component is specified, all available components will be checked.
  • SetHealthy defines the health status of a given component as "healthy".
  • SetUnhealthy defines the health status of a given component as "not healthy" and requires a reason.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Options(
	fx.Provide(
		newServiceHealth,
	),
	fx.Invoke(
		useHealthEndpoint,
	),
)

Functions

This section is empty.

Types

type HealthEndpoint

type HealthEndpoint struct {
	fx.In

	Health *ServiceHealth
}

func (*HealthEndpoint) Handle

func (e *HealthEndpoint) Handle(c *fiber.Ctx) error

type ServiceHealth

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

func (*ServiceHealth) IsHealthy

func (s *ServiceHealth) IsHealthy(component ...string) (bool, string)

func (*ServiceHealth) SetHealthy

func (s *ServiceHealth) SetHealthy(component string)

func (*ServiceHealth) SetUnhealthy

func (s *ServiceHealth) SetUnhealthy(component string, reason string)

Jump to

Keyboard shortcuts

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