Melkeydev / go-blueprint

Go-blueprint allows users to spin up a quick Go project using a popular framework
MIT License
2.07k stars 141 forks source link

[Feature Request] Enhance Health Function For Redis, similar to other databases (SQL). #230

Open H0llyW00dzZ opened 1 month ago

H0llyW00dzZ commented 1 month ago

Tell us about your feature request

It is also possible to enhance the Health function for Redis, similar to other databases (SQL).

For example, I've been using two databases: Redis for caching and MySQL for data storage: image

Disclaimer

Ujstor commented 2 weeks ago

@H0llyW00dzZ Did I get this right... A second database is needed if you won't implement a health function for Redis similar to the SQL databases that you implemented?

I am asking because in PR #200 you implemented a health function for SQL databases. I don't remember why Redis and MongoDB were not implemented in this PR

H0llyW00dzZ commented 2 weeks ago

@H0llyW00dzZ Did I get this right... A second database is needed if you won't implement a health function for Redis similar to the SQL databases that you implemented?

I am asking because in PR #200 you implemented a health function for SQL databases. I don't remember why Redis and MongoDB were not implemented in this PR

@Ujstor That was only for MySQL. Here's an example for Redis:

{
    "redis_health": {
        "status": "up",
        "message": "Redis connection pool utilization is high",
        "stats": {
            "version": "7.0.15",
            "mode": "standalone",
            "connected_clients": "10",
            "memory": { "used": { "mb": "22.38", "gb": "0.02" }, "peak": { "mb": "46.57", "gb": "0.05" }, "free": { "mb": "1130.00", "gb": "1.10" }, "percentage": "1.98%" },
            "uptime_stats": "6 days, 3 hours, 37 minutes, 20 seconds",
            "uptime": [{ "day": "6" }, { "hour": "3" }, { "minute": "37" }, { "second": "20" }],
            "pooling": { "figures": { "hits": "10", "misses": "2", "timeouts": "0", "total": "4", "stale": "9", "idle": "5", "active": "0", "percentage": "62.50%" }, "observed_total": "26" }
        }
    }
}

Also, note that the redis_health functionality for health stats is dynamic and depends on the configuration.

Example source:

https://github.com/H0llyW00dzZ/My-RESTAPIs-Boilerplate/blob/master/backend/internal/database/mysql_redis.go

Ujstor commented 2 weeks ago

Open PR when you are ready. If you can do the same thing for MongoDB, that would be nice. That way, the health func for all db-s would provide useful information

H0llyW00dzZ commented 2 weeks ago

Open PR when you are ready. If you can do the same thing for MongoDB, that would be nice. That way, the health func for all db-s would provide useful information

I will need to look into the MongoDB package later.