mongo

package module
v0.0.0-...-a499989 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package mongo contains a helper function for ensuring mongo is up or down

Index

Constants

This section is empty.

Variables

IsMongoAlive is a global atomic bool that can be used to check if mongo is alive or not.

View Source
var MongoError error

MongoError is a global error that shows the last error that occurred with mongo.

Functions

func InitializeDaemonChecker

func InitializeDaemonChecker(callback func(bool))

InitializeDaemonChecker is a function that will check if mongo is up or down every 5 seconds and will invoke your callback function with the status of the connection after 10 seconds of tcp timeouts it will flag as false or every 5 seconds return true to you. You have to manage state if it has changed Something like

mongo.InitializeDaemonChecker(mongoDaemonCallback)

func mongoDaemonCallback(status bool) {
	type response struct {
		Status bool `json:"status"`
	}
	var json response
	json.Status = status
	PublishWebSocketJSON("Mongo", json)
}

Types

This section is empty.

Jump to

Keyboard shortcuts

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