You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Allow custom health checks with this standard interface [Checker](https://github.com/core-go/health/blob/main/checker.go):
71
-
```json
72
+
```go
72
73
package health
73
74
74
75
import "context"
@@ -79,8 +80,9 @@ A health check in microservices is a mechanism that ensures each service is func
79
80
Build(ctx context.Context, data map[string]interface{}, err error) map[string]interface{}
80
81
}
81
82
```
83
+
82
84
- Build the response JSON from many custom health checks by this GO function [Check](https://github.com/core-go/health/blob/main/check.go)
83
-
- This function can be called by http handler ([gin](https://github.com/gin-gonic/gin), [echo](https://github.com/labstack/echo), [mux](https://github.com/gorilla/mux), [go-chi](https://github.com/go-chi/chi))
85
+
- This function can be called by http handler ([gin](https://github.com/gin-gonic/gin), [echo](https://github.com/labstack/echo), [mux](https://github.com/gorilla/mux), [go-chi](https://github.com/go-chi/chi))
84
86
- Implement basic checks
85
87
- CPU, memory, disk space: not yet implemented.
86
88
- Cache (Redis, Memcached)
@@ -101,44 +103,38 @@ A health check in microservices is a mechanism that ensures each service is func
101
103
- <b>Features</b>:
102
104
- Check connectivity to cache servers (Redis, Memcached).
103
105
- Redis: support [go-redis/redis](https://github.com/core-go/health/blob/main/redis/v9/health_checker.go) and [garyburd/redigo](https://github.com/core-go/health/blob/main/redigo/health_checker.go). The sample is at [go-admin](https://github.com/project-samples/go-admin).
104
-
- nodejs library for Redis is at [redis-plus](https://www.npmjs.com/package/redis-plus)
105
106
- Validate cache hit/miss ratio and performance metrics.
106
107
107
-
#### Database Health Check Library
108
+
#### DatabaseHealthCheckLibraries
108
109
- <b>Purpose</b>: Monitors the health of database connections
109
110
- <b>Features</b>:
110
111
- Check connectivity and response time for various databases (SQL, NoSQL).
111
112
- [sql](https://github.com/core-go/health/blob/main/sql/health_checker.go). The sample is at [go-sql-sample](https://github.com/go-tutorials/go-sql-sample).
112
-
- nodejs library for My SQL is at [mysql2-core](https://www.npmjs.com/package/mysql2-core). The sample is at [sql-modular-sample](https://github.com/source-code-template/sql-modular-sample).
113
-
- nodejs library for Oracle is at [oracle-core](https://www.npmjs.com/package/oracle-core).
114
-
- nodejs library for Postgres is at [pg-extension](https://www.npmjs.com/package/pg-extension).
115
-
- nodejs library for MS SQL is at [mssql-core](https://www.npmjs.com/package/mssql-core).
116
113
- [mongo](https://github.com/core-go/health/blob/main/mongo/health_checker.go). The sample is at [go-mongo-sample](https://github.com/go-tutorials/go-mongo-sample).
117
-
- nodejs library for mongo is at [mongodb-extension](https://www.npmjs.com/package/mongodb-extension). The sample is at [mongo-modular-sample](https://github.com/source-code-template/mongo-modular-sample).
118
114
- [dynamodb](https://github.com/core-go/health/blob/main/dynamodb/health_checker.go). The sample is at [go-dynamodb-tutorial](https://github.com/go-tutorials/go-dynamodb-tutorial).
119
115
- [firestore](https://github.com/core-go/health/blob/main/firestore/health_checker.go). The sample is at [go-firestore-sample](https://github.com/go-tutorials/go-firestore-sample).
120
116
- [elasticsearch](https://github.com/core-go/health/blob/main/elasticsearch/v8/health_checker.go). The sample is at [go-elasticsearch-sample](https://github.com/go-tutorials/go-elasticsearch-sample).
121
117
- [cassandra](https://github.com/core-go/health/blob/main/cassandra/health_checker.go). The sample is at [go-cassandra-sample](https://github.com/go-tutorials/go-cassandra-sample).
122
118
- [hive](https://github.com/core-go/health/blob/main/hive/health_checker.go). The sample is at [go-hive-sample](https://github.com/go-tutorials/go-hive-sample).
123
119
- Provide detailed status messages and error handling.
124
120
125
-
#### Message Queue Health Check Library
121
+
#### MessageQueueHealthCheckLibraries
126
122
- <b>Purpose</b>: Ensures message queues are operational.
127
123
- <b>Features</b>:
128
124
- Check connectivity and queue depth for different message brokers.
129
125
- [Amazon SQS](https://github.com/core-go/health/blob/main/sqs/health_checker.go). The sample is at [go-amazon-sqs-sample](https://github.com/project-samples/go-amazon-sqs-sample).
130
126
- [Google Pub/Sub](https://github.com/core-go/health/blob/main/pubsub/health_checker.go). The sample is at [go-pubsub-sample](https://github.com/project-samples/go-pubsub-sample).
131
-
- health check for nodejs is at [google-pubsub](https://www.npmjs.com/package/google-pubsub). The sample is at [pubsub-sample](https://github.com/typescript-tutorial/pubsub-sample).
127
+
- health check for nodejs is at [google-pubsub](https://www.npmjs.com/package/google-pubsub). The sample is at [pubsub-sample](https://github.com/typescript-tutorial/pubsub-sample).
132
128
- [Kafka](https://github.com/core-go/health/blob/main/kafka/health_checker.go). The sample is at [go-kafka-sample](https://github.com/project-samples/go-kafka-sample).
133
-
- health check for nodejs is at [kafka-plus](https://www.npmjs.com/package/kafka-plus). The sample is at [kafka-sample](https://github.com/typescript-tutorial/kafka-sample).
129
+
- health check for nodejs is at [kafka-plus](https://www.npmjs.com/package/kafka-plus). The sample is at [kafka-sample](https://github.com/typescript-tutorial/kafka-sample).
134
130
- [NATS](https://github.com/core-go/health/blob/main/nats/health_checker.go). The sample is at [go-nats-sample](https://github.com/project-samples/go-nats-sample).
135
-
- health check for nodejs is at [NATS](https://www.npmjs.com/package/nats-plus). The sample is at [nats-sample](https://github.com/typescript-tutorial/nats-sample)
131
+
- health check for nodejs is at [NATS](https://www.npmjs.com/package/nats-plus). The sample is at [nats-sample](https://github.com/typescript-tutorial/nats-sample)
136
132
- [Active MQ](https://github.com/core-go/health/blob/main/activemq/health_checker.go). The sample is at [go-active-mq-sample](https://github.com/project-samples/go-active-mq-sample).
137
-
- health check for nodejs is at [activemq](https://www.npmjs.com/package/activemq). The sample is at [activemq-sample](https://github.com/typescript-tutorial/activemq-sample)
133
+
- health check for nodejs is at [activemq](https://www.npmjs.com/package/activemq). The sample is at [activemq-sample](https://github.com/typescript-tutorial/activemq-sample)
138
134
- [RabbitMQ](https://github.com/core-go/health/blob/main/rabbitmq/health_checker.go). The sample is at [go-rabbit-mq-sample](https://github.com/project-samples/go-rabbit-mq-sample).
139
135
- health check for nodejs is at [rabbitmq-ext](https://www.npmjs.com/package/rabbitmq-ext). The sample is at [rabbitmq-sample](https://github.com/typescript-tutorial/rabbitmq-sample)
140
136
- [IBM MQ](https://github.com/core-go/health/blob/main/ibmmq/health_checker.go). The sample is at [go-ibm-mq-sample](https://github.com/project-samples/go-ibm-mq-sample).
141
-
- health check for nodejs is at [ibmmq-plus](https://www.npmjs.com/package/ibmmq-plus). The sample is at [ibmmq-sample](https://github.com/typescript-tutorial/ibmmq-sample).
137
+
- health check for nodejs is at [ibmmq-plus](https://www.npmjs.com/package/ibmmq-plus). The sample is at [ibmmq-sample](https://github.com/typescript-tutorial/ibmmq-sample).
142
138
- Monitor message lag and processing time (Not yet implemented)
143
139
144
140
### FutureLibraries to develop
@@ -163,7 +159,39 @@ A health check in microservices is a mechanism that ensures each service is func
163
159
- [handler](https://github.com/core-go/health/blob/main/handler.go), to support [Gorilla mux](https://github.com/gorilla/mux) and [Go-chi](https://github.com/go-chi/chi). The sample is at [go-sql-sample](https://github.com/go-tutorials/go-sql-sample).
164
160
- [echo handler](https://github.com/core-go/health/blob/main/echo/handler.go) to support [Echo](https://github.com/labstack/echo). The sample is at [go-sql-echo-sample](https://github.com/go-tutorials/go-sql-echo-sample).
165
161
- [gin handler](https://github.com/core-go/health/blob/main/gin/handler.go) to support [Gin](https://github.com/gin-gonic/gin). The sample is at is at [go-sql-gin-sample](https://github.com/go-tutorials/go-sql-gin-sample).
166
-
- for nodejs, we have [express-ext](https://www.npmjs.com/package/express-ext) to integrate with [express](https://www.npmjs.com/package/express). The sample is at is at [mongo-modular-sample](https://github.com/source-code-template/mongo-modular-sample).
162
+
163
+
### Benefits and Challenges:
164
+
#### Benefits:
165
+
- ImprovedReliability: Continuous monitoring of services ensures quick detection and resolution of issues.
166
+
- Scalability: Supports growth by maintaining health across distributed systems.
167
+
- BetterResourceManagement: Helps optimize resource usage and prevent failures.
168
+
169
+
#### Challenges:
170
+
- Overhead: Adding health checks can introduce some performance overhead.
171
+
- Complexity: Requires careful planning and integration to avoid false positives and negatives.
172
+
- Maintenance: Health check implementations need regular updates to stay relevant and effective.
173
+
174
+
## Appendix
175
+
### HealthCheckfor nodejs
176
+
#### DatabaseHealthCheckLibraries
177
+
- Redis: [redis-plus](https://www.npmjs.com/package/redis-plus), to wrap and simplify [redis](https://www.npmjs.com/package/redis).
178
+
- Mongo: [mongodb-extension](https://www.npmjs.com/package/mongodb-extension), to wrap and simplify [mongodb](https://www.npmjs.com/package/mongodb). The sample is at [mongo-modular-sample](https://github.com/source-code-template/mongo-modular-sample).
179
+
- MySQL: [mysql2-core](https://www.npmjs.com/package/mysql2-core), to wrap and simplify [mysql2](https://www.npmjs.com/package/mysql2). The sample is at [sql-modular-sample](https://github.com/source-code-template/sql-modular-sample).
180
+
- Oracle: [oracle-core](https://www.npmjs.com/package/oracle-core), to wrap and simplify [oracledb](https://www.npmjs.com/package/oracledb).
181
+
- Postgres: [pg-extension](https://www.npmjs.com/package/pg-extension), to wrap and simplify [pg](https://www.npmjs.com/package/pg).
182
+
- MSSQL: [mssql-core](https://www.npmjs.com/package/mssql-core), to wrap and simplify [mssql](https://www.npmjs.com/package/mssql).
183
+
- SQLite: [sqlite3-core](https://www.npmjs.com/package/sqlite3-core) to wrap and simplify [sqlite3](https://www.npmjs.com/package/sqlite3).
184
+
185
+
#### MessageQueueHealthCheckLibraries
186
+
- Kafka: [kafka-plus](https://www.npmjs.com/package/kafka-plus), to wrap and simplify [kafkajs](https://www.npmjs.com/package/kafkajs). The sample is at [kafka-sample](https://github.com/typescript-tutorial/kafka-sample).
187
+
- RabbitMQ: [rabbitmq-ext](https://www.npmjs.com/package/rabbitmq-ext), to wrap and simplify [amqplib](https://www.npmjs.com/package/amqplib). The sample is at [rabbitmq-sample](https://github.com/typescript-tutorial/rabbitmq-sample).
188
+
- GooglePub/Sub: [google-pubsub](https://www.npmjs.com/package/google-pubsub), to wrap and simplify [@google-cloud/pubsub](https://www.npmjs.com/package/@google-cloud/pubsub). The sample is at [pubsub-sample](https://github.com/typescript-tutorial/pubsub-sample)
189
+
- IBMMQ: [ibmmq-plus](https://www.npmjs.com/package/ibmmq-plus), to wrap and simplify [ibmmq](https://www.npmjs.com/package/ibmmq). The sample is at [ibmmq-sample](https://github.com/typescript-tutorial/ibmmq-sample).
190
+
- ActiveMQ: [activemq](https://www.npmjs.com/package/activemq), to wrap and simplify [amqplib](https://www.npmjs.com/package/amqplib). The sample is at [activemq-sample](https://github.com/typescript-tutorial/activemq-sample).
191
+
- NATS: [nats-plus](https://www.npmjs.com/package/nats-plus), to wrap and simplify [nats](https://www.npmjs.com/package/nats). The sample is at [nats-sample](https://github.com/typescript-tutorial/nats-sample).
192
+
193
+
#### Integration with ExistingSystems
194
+
- for nodejs, we have [express-ext](https://www.npmjs.com/package/express-ext) to integrate with [express](https://www.npmjs.com/package/express). The sample is at is at [mongo-modular-sample](https://github.com/source-code-template/mongo-modular-sample).
167
195
168
196
## Installation
169
197
Please make sure to initialize a Go module before installing core-go/health:
0 commit comments