From 23ae0b9028abe7f00f8e413136d79855a74c548f Mon Sep 17 00:00:00 2001 From: Duc Nguyen Date: Sun, 1 Sep 2024 16:52:02 +0700 Subject: [PATCH] Refactor redis --- README.md | 2 +- redigo/health_checker.go | 2 +- redis/v8/health_checker.go | 4 ++-- redis/v9/health_checker.go | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6c83265..f6087cf 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A health check in microservices is a mechanism that ensures each service is func - You can refer to [Microservice Health Check](https://www.linkedin.com/pulse/microservice-health-check-go-nodejs-duc-nguyen-qunvc) at my [Linked In](https://vn.linkedin.com/in/duc-nguyen-437240239?trk=article-ssr-frontend-pulse_publisher-author-card) for more details. -![health](https://cdn-images-1.medium.com/max/800/1*k-VjYL3UL9Zohwzas4nb8Q.png) +![health](https://cdn-images-1.medium.com/max/800/1*NreJfea6tHobxMpiq96PPQ.png) ### Use Cases of Health Check #### Service Availability Monitoring: diff --git a/redigo/health_checker.go b/redigo/health_checker.go index b861e20..0518dbb 100644 --- a/redigo/health_checker.go +++ b/redigo/health_checker.go @@ -2,7 +2,7 @@ package redis import ( "context" - "github.com/garyburd/redigo/redis" + "github.com/gomodule/redigo/redis" "time" ) diff --git a/redis/v8/health_checker.go b/redis/v8/health_checker.go index 2a24c39..f1c9ca1 100644 --- a/redis/v8/health_checker.go +++ b/redis/v8/health_checker.go @@ -13,14 +13,14 @@ type HealthChecker struct { timeout time.Duration } -func NewRedisHealthChecker(db *redis.Client, name string, timeouts ...time.Duration) *HealthChecker { +func NewRedisHealthChecker(client *redis.Client, name string, timeouts ...time.Duration) *HealthChecker { var timeout time.Duration if len(timeouts) >= 1 { timeout = timeouts[0] } else { timeout = 4 * time.Second } - return &HealthChecker{client: db, name: name, timeout: timeout} + return &HealthChecker{client: client, name: name, timeout: timeout} } func NewHealthChecker(db *redis.Client, options ...string) *HealthChecker { diff --git a/redis/v9/health_checker.go b/redis/v9/health_checker.go index 09cee6d..65213c9 100644 --- a/redis/v9/health_checker.go +++ b/redis/v9/health_checker.go @@ -1,4 +1,4 @@ -package v9 +package redis import ( "context" @@ -13,14 +13,14 @@ type HealthChecker struct { timeout time.Duration } -func NewRedisHealthChecker(db *redis.Client, name string, timeouts ...time.Duration) *HealthChecker { +func NewRedisHealthChecker(client *redis.Client, name string, timeouts ...time.Duration) *HealthChecker { var timeout time.Duration if len(timeouts) >= 1 { timeout = timeouts[0] } else { timeout = 4 * time.Second } - return &HealthChecker{client: db, name: name, timeout: timeout} + return &HealthChecker{client: client, name: name, timeout: timeout} } func NewHealthChecker(db *redis.Client, options ...string) *HealthChecker {