Skip to content

redhug1/dp-mongodb

 
 

Repository files navigation

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

Using mongo checker function currently pings a mongo client, further work to check mongo queries based on an applications requirements (level of access and to which databases and collections).

Read the Health Check Specification for details.

Instantiate a mongo health checker

import mongoHealth "github.com/ONSdigital/dp-mongo/health"

...

    mongoClient := mongoHealth.NewClient(<mgo session>)

    mongoHealth := mongoHealth.CheckClient{
        client: mongoClient,
        healthcheck: mongoHealth.Healthcheck,
    }
...

Call mongo health checker with mongoHealth.Checker(context.Background()) and this will return a 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 .Create() function

Contributing

See CONTRIBUTING for details.

License

Copyright © 2020, Office for National Statistics (https://www.ons.gov.uk)

Released under MIT license, see LICENSE for details.

About

A mongo db library for Go.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.8%
  • Makefile 0.2%