1.0.2 • Published 1 year ago

healthcheck-lib v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Healcheck Lib

Orlinski-Zawrzykraj

Introduccion

Ésta es una librería personalizada para realizar chequeo de status en la infraestructura de un servicio (redis, mongodb, mysqldb y rabbitmq).

Es configurable para que solo se realice el chequeo sobre los servicios de infraestructura que realmente se encuentran conectados al servicio.

Forma de uso

Intalación

Correr en el proyecto: npm install healthcheck-lib.

Uso

Importar y utilizar, indicando los servicios que queremos validar el status y aquellos que no.

Por ejemplo si solo quisiéramos chequear estado de redis y rabbitmq:

import healthcheck from 'healthchek-lib';

const servicesToCheck = new healthcheck.ServicesToCheck(true,false,true,false);
const healthCheckService = new healthcheck.HealthCheckService(servicesToCheck);
const infoHealthCheck = await healtCheckService.ping();

Eso arrojaría un resultado similar al siguiente:

{
    "status": "OK",
    "data": {
        "rabbitMqStatitics": {
			"connection_closed": 0,
			"channel_closed": 0,
			"consumer_deleted": 0,
			"exchange_deleted": 0,
			"queue_deleted": 0,
			"vhost_deleted": 0,
			"node_node_deleted": 0,
			"channel_consumer_deleted": 0
		},
		"redisMsg": "PONG"
	}
}

Y si en todo caso quisiéramos el status de todos los servicios, arrojaría algo similar a:

{
	"status": "OK",
	"data": {
		"mysqlMsg": "PONG",
		"rabbitMqStatitics": {
			"connection_closed": 0,
			"channel_closed": 0,
			"consumer_deleted": 0,
			"exchange_deleted": 0,
			"queue_deleted": 0,
			"vhost_deleted": 0,
			"node_node_deleted": 0,
			"channel_consumer_deleted": 0
		},
		"redisMsg": "PONG",
		"mongoMsg": "PONG"
	}
}

Configuración

En el proyecto donde importe la librería, deberá tener un archivo .env con una configuración similar a la siguiente:

HOST_RABBITMQ=http://localhost:15672/api/nodes
RABBITMQ_USER=user
RABBITMQ_PASS=password
DATABASE_USER=root
DATABASE_HOST=localhost
DATABASE_NAME=example1
DATABASE_PASS=secret
DATABASE_PORT=3306
REDIS_URL=redis://localhost:6379
MONGO_URL=mongodb://localhost:27017
MONGO_DB_NAME=test
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago