Skip to content

Commit

Permalink
Tweak healthcheck for redis to timeout after a second
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Nov 4, 2024
1 parent d67f20c commit d29f26a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions backends/rapidpro/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -709,12 +709,17 @@ func (b *backend) HttpAccess() *httpx.AccessConfig {
// Health returns the health of this backend as a string, returning "" if all is well
func (b *backend) Health() string {
// test redis
rc := b.rp.Get()
defer rc.Close()
_, redisErr := rc.Do("PING")
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
rc, redisErr := b.rp.GetContext(ctx)
cancel()

if redisErr == nil {
defer rc.Close()
_, redisErr = rc.Do("PING")
}

// test our db
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
ctx, cancel = context.WithTimeout(context.Background(), time.Second)
dbErr := b.db.PingContext(ctx)
cancel()

Expand Down

0 comments on commit d29f26a

Please sign in to comment.