dp-mongodb
A mongodb library for DP.
Getting started
Setting up mongo
Using brew, type brew install mongo or the latest binaries can be downloaded here
Running mongo
Follow instructions from mongo db manual
health package
The mongo checker function currently pings the mongo client, and checks that all collections given when the checker was created, actually exist.
Read the Health Check Specification for details.
Instantiate a mongo health checker
import mongoHealth "github.com/ONSdigital/dp-mongo/health"
import mongoDriver "github.com/ONSdigital/dp-mongo/mongodb"
...
healthClient := mongoHealth.NewClientWithCollections(<mongoDriver.MongoConnection>, <map[mongoHealth.Database][]mongoHealth.Collection>)
...
Calling mongo health checker: healthClient.Checker(context.Context, *healthcheck.CheckState)
will fill out the check object like so:
{
"name": "string",
"status": "string",
"message": "string",
"last_checked": "ISO8601 - UTC date time",
"last_success": "ISO8601 - UTC date time",
"last_failure": "ISO8601 - UTC date time"
}
Configuration
Configuration of the health check takes place via arguments passed to the NewClient() or NewClientWithCollections()
functions
Contributing
See CONTRIBUTING for details.
License
Copyright © 2024, Office for National Statistics (https://www.ons.gov.uk)
Released under MIT license, see LICENSE for details.