common

package module
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: AGPL-3.0 Imports: 10 Imported by: 8

README

common-healthcheck Build Status Coverage Status GoDoc Go Report Card

All Cloudtrust microservices send metrics to InfluxDB, traces to Jaeger, technical logs to Redis, and errors to Sentry. The health of all those components is monitored with health checks. Because they are used in every microservice, this library with all the common health checks was created.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeHealthCheckerLoggingMW

func MakeHealthCheckerLoggingMW(logger log.Logger) func(HealthChecker) HealthChecker

MakeHealthCheckerLoggingMW makes a logging middleware for the health check modules.

func MakeValidationMiddleware

func MakeValidationMiddleware(validValues map[string]struct{}) func(HealthChecker) HealthChecker

MakeValidationMiddleware makes a middleware that validate the health check name comming from the HTTP route. Let's imagine we have a module with the healthchecks "ping", "create", and "delete". In the validValues map, we list the health check authorized, with "" that is a special value for executing all healthchecks.

var validValues = map[string]struct{}{
  "":       struct{}{},
	 "ping":   struct{}{},
  "create": struct{}{},
  "delete": struct{}{},
}

Types

type CockroachClient

type CockroachClient interface {
	Ping() error
}

CockroachClient is the interface of the cockroach client.

type CockroachModule

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

CockroachModule is the health check module for cockroach.

func NewCockroachModule

func NewCockroachModule(cockroach CockroachClient, enabled bool) *CockroachModule

NewCockroachModule returns the cockroach health module.

func (*CockroachModule) HealthCheck

func (m *CockroachModule) HealthCheck(_ context.Context, name string) (json.RawMessage, error)

HealthCheck executes the desired cockroach health check.

type ErrInvalidHCName

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

ErrInvalidHCName is the error returned when there is a health request for an unknown healthcheck name.

func (*ErrInvalidHCName) Error

func (e *ErrInvalidHCName) Error() string

type FlakiClient

type FlakiClient interface {
	NextID(context.Context) (string, error)
}

FlakiClient is the interface of the Flaki client.

type FlakiModule

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

FlakiModule is the health check module for Flaki.

func NewFlakiModule

func NewFlakiModule(client FlakiClient, enabled bool) *FlakiModule

NewFlakiModule returns the Flaki health module.

func (*FlakiModule) HealthCheck

func (m *FlakiModule) HealthCheck(_ context.Context, name string) (json.RawMessage, error)

HealthCheck executes the desired influx health check.

type HTTPClient

type HTTPClient interface {
	Get(string) (*http.Response, error)
}

HTTPClient is the interface of the http client used to get health check status.

type HealthChecker

type HealthChecker interface {
	HealthCheck(context.Context, string) (json.RawMessage, error)
}

HealthChecker is the interface of the health check modules.

type InfluxClient

type InfluxClient interface {
	Ping(timeout time.Duration) (time.Duration, string, error)
}

InfluxClient is the interface of the influx client.

type InfluxModule

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

InfluxModule is the health check module for influx.

func NewInfluxModule

func NewInfluxModule(influx InfluxClient, enabled bool) *InfluxModule

NewInfluxModule returns the influx health module.

func (*InfluxModule) HealthCheck

func (m *InfluxModule) HealthCheck(_ context.Context, name string) (json.RawMessage, error)

HealthCheck executes the desired influx health check.

type JaegerModule

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

JaegerModule is the health check module for jaeger.

func NewJaegerModule

func NewJaegerModule(httpClient HTTPClient, collectorHealthHostPort string, enabled bool) *JaegerModule

NewJaegerModule returns the jaeger health module.

func (*JaegerModule) HealthCheck

func (m *JaegerModule) HealthCheck(_ context.Context, name string) (json.RawMessage, error)

HealthCheck executes the desired jaeger health check.

type RedisClient

type RedisClient interface {
	Do(cmd string, args ...interface{}) (interface{}, error)
}

RedisClient is the interface of the redis client.

type RedisModule

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

RedisModule is the health check module for redis.

func NewRedisModule

func NewRedisModule(redis RedisClient, enabled bool) *RedisModule

NewRedisModule returns the redis health module.

func (*RedisModule) HealthCheck

func (m *RedisModule) HealthCheck(_ context.Context, name string) (json.RawMessage, error)

HealthCheck executes the desired influx health check.

type SentryClient

type SentryClient interface {
	URL() string
}

SentryClient is the interface of the sentry client.

type SentryModule

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

SentryModule is the health check module for sentry.

func NewSentryModule

func NewSentryModule(sentry SentryClient, httpClient HTTPClient, enabled bool) *SentryModule

NewSentryModule returns the sentry health module.

func (*SentryModule) HealthCheck

func (m *SentryModule) HealthCheck(_ context.Context, name string) (json.RawMessage, error)

HealthCheck executes the desired influx health check.

type Status

type Status int

Status is the status of the health check.

const (
	// OK is the status for a successful health check.
	OK Status = iota
	// KO is the status for an unsuccessful health check.
	KO
	// Deactivated is the status for a service that is deactivated, e.g. we can disable error tracking, instrumenting, tracing,...
	Deactivated
)

func (Status) String

func (i Status) String() string

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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