// Checker calls an api health endpoint and  updates the provided CheckState accordingly
Checker calls an api health endpoint and  updates the provided CheckState accordingly
// Checker calls an api health endpoint and updates the provided CheckState accordingly
func (c *CheckMongoClient) Checker(ctx context.Context, state *healthcheck.CheckState) error {
	err := c.healthcheck(ctx)
	if err != nil {
		state.Update(healthcheck.StatusCritical, err.Error(), 0)
		return nil
	}
	msg := healthyMessage
	if c.databaseCollection != nil && len(c.databaseCollection) > 0 {
		err = c.checkCollections(ctx)
		if err != nil {
			log.Error(ctx, "Error checking collections in mongo", err)
			state.Update(healthcheck.StatusCritical, err.Error(), 0)
			return nil
		}
		msg += healthyCollectionsMessage
	}
	state.Update(healthcheck.StatusOK, msg, 0)
	return nil
}
func ( c * CheckMongoClient ) Checker ( ctx context . Context , state * healthcheck . CheckState ) error { err := c . healthcheck ( ctx ) if err != nil { state . Update ( healthcheck . StatusCritical , err . Error ( ) , 0 ) return nil } msg := healthyMessage if c . databaseCollection != nil && len ( c . databaseCollection ) > 0 { err = c . checkCollections ( ctx ) if err != nil { log . Error ( ctx , " " , err ) state . Update ( healthcheck . StatusCritical , err . Error ( ) , 0 ) return nil } msg += healthyCollectionsMessage } state . Update ( healthcheck . StatusOK , msg , 0 ) return nil }
Checker calls an api health endpoint and  updates the provided CheckState accordingly
Checker calls an api health endpoint and updates the provided CheckState accordingly