Categorygithub.com/ONSdigital/dp-mongodb/v2
modulepackage
2.8.0
Repository: https://github.com/onsdigital/dp-mongodb.git
Documentation: pkg.go.dev

# README

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.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# Functions

Close represents mongo session closing within the context deadline.
WithLastUpdatedUpdate adds last_updated to updateDoc.
WithNamespacedLastUpdatedUpdate adds unique timestamp to updateDoc.
WithNamespacedUniqueTimestampQuery adds unique timestamps to queryDoc sub-docs.
WithNamespacedUniqueTimestampUpdate adds unique timestamp to updateDoc.
WithNamespacedUpdates adds all timestamps to updateDoc.
WithUniqueTimestampQuery adds unique timestamp to queryDoc.
WithUniqueTimestampUpdate adds unique timestamp to updateDoc.
WithUpdates adds all timestamps to updateDoc.

# Constants

keep these in sync with Timestamps tags below.
keep these in sync with Timestamps tags below.

# Structs

Timestamps represent an object containing time stamps keep these in sync with above const.

# Interfaces

Graceful represents an interface to the shutdown method.