health

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2021 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const ServiceName = "mongodb"

ServiceName mongodb

Variables

View Source
var (
	ErrorCollectionDoesNotExist = errors.New("collection not found in database")
	ErrorWithMongoDBConnection  = errors.New("unable to connect with MongoDB")
)

List of errors

View Source
var (
	// HealthyMessage is the message that will be used in healthcheck when mongo is Healthy and all the collections exist
	HealthyMessage = "mongodb is OK and all expected collections exist"
)

Functions

This section is empty.

Types

type CheckMongoClient

type CheckMongoClient struct {
	Client      Client
	Healthcheck Healthcheck
}

CheckMongoClient is an implementation of the mongo client with a healthcheck

func (*CheckMongoClient) Checker

func (c *CheckMongoClient) Checker(ctx context.Context, state *healthcheck.CheckState) error

Checker calls an api health endpoint and updates the provided CheckState accordingly

type Client

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

Client provides a healthcheck.Client implementation for health checking the service

func NewClient

func NewClient(db *mgo.Session) *Client

NewClient returns a new health check client using the given service

func NewClientWithCollections added in v1.5.0

func NewClientWithCollections(db *mgo.Session, clientDatabaseCollection map[Database][]Collection) *Client

NewClientWithCollections returns a new health check client containing the collections using the given service

func (*Client) Healthcheck

func (m *Client) Healthcheck(ctx context.Context) (res string, err error)

Healthcheck calls service to check its health status

type Collection added in v1.5.0

type Collection string

Collection a list of mongo types

type Database added in v1.5.0

type Database string

Database a list of mongo types

type Healthcheck

type Healthcheck = func(context.Context) (string, error)

Healthcheck health check function

Jump to

Keyboard shortcuts

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