xhealth

package
v0.4.18 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 10 Imported by: 3

Documentation

Overview

SPDX-FileCopyrightText: 2017 Comcast Cable Communications Management, LLC SPDX-License-Identifier: Apache-2.0

SPDX-FileCopyrightText: 2017 Comcast Cable Communications Management, LLC SPDX-License-Identifier: Apache-2.0

SPDX-FileCopyrightText: 2017 Comcast Cable Communications Management, LLC SPDX-License-Identifier: Apache-2.0

SPDX-FileCopyrightText: 2017 Comcast Cable Communications Management, LLC SPDX-License-Identifier: Apache-2.0

SPDX-FileCopyrightText: 2017 Comcast Cable Communications Management, LLC SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyChecks added in v0.0.3

func ApplyChecks(first *health.Config, rest ...*health.Config) func(ApplyChecksIn) error

ApplyChecks is an uber/fx Invoke function that allows checks created outside the uber/fx App to be registered with a Health component.

func New

func New(o Options, logger *zap.Logger, listener health.IStatusListener) (health.IHealth, error)

New constructs an IHealth instance for the given environment. If either the DisableLogging option field is set or the given logger is nil, logging will be disabled on the returned health object. The listener is optional.

func NewHealthLoggerAdapter

func NewHealthLoggerAdapter(logger *zap.Logger) healthlog.Logger

NewHealthLoggerAdapter adapts a go-kit logger onto the go-logger package's logger interface

func OnStart

func OnStart(logger *zap.Logger, h health.IHealth) func(context.Context) error

OnStart returns an uber/fx Lifecycle hook for startup

func OnStop

func OnStop(logger *zap.Logger, h health.IHealth) func(context.Context) error

OnStop returns an uber/fx Lifecycle hook for shutdown

func Unmarshal

func Unmarshal(configKey string) func(HealthIn) (HealthOut, error)

Unmarshal returns an uber/fx provider that reads configuration from a Viper instance and initializes the health infrastructure.

Types

type ApplyChecksIn added in v0.0.3

type ApplyChecksIn struct {
	fx.In

	Health health.IHealth
}

type Handler

type Handler http.Handler

func NewHandler

func NewHandler(h health.IHealth, custom map[string]interface{}) Handler

type HealthIn

type HealthIn struct {
	fx.In

	// Logger is the required go-kit logger that will receive health logging output
	Logger *zap.Logger

	// Unmarshaller is the required configuration unmarshaller strategy
	Unmarshaller config.Unmarshaller

	// Lifecycle is used to bind the health service the the uber/fx App lifecycle
	Lifecycle fx.Lifecycle

	// StatusListener is the optional listener for health status changes
	StatusListener health.IStatusListener `optional:"true"`

	// Config is an optional check.  If both this field and Configs are set, both fields
	// are added.
	Config *health.Config `optional:"true"`

	// Configs is an optional slice of checks.  If both this field and Config are set, both
	// fields are added.
	Configs []*health.Config `optional:"true"`
}

HealthIn defines the set of dependencies for instantiating an InVision health service and binding that service to the application lifecycle.

type HealthOut

type HealthOut struct {
	fx.Out

	Health  health.IHealth
	Handler Handler
}

HealthOut defines the components emitted by this package

type NopCheckable added in v0.0.3

type NopCheckable struct {
	Details interface{}
}

NopCheckable is an ICheckable that always returns success. This type is useful when an app only wants a health endpoint to indicate its own liveness, rather than checking any external dependencies.

func (NopCheckable) Status added in v0.0.3

func (nc NopCheckable) Status() (interface{}, error)

type Options

type Options struct {
	// DisableLogging controls whether the created health service logs anything.  The default is false,
	// meaning logging is enabled.
	DisableLogging bool

	// Custom is an optional map passed to NewHandler that is included in all responses to health checks
	Custom map[string]interface{}
}

Options holds the available configuration options for the health infrastructure

Jump to

Keyboard shortcuts

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