From 18df8a36f6044d4b72e9eaf2b53c981ca2b583c0 Mon Sep 17 00:00:00 2001 From: Vincent Boutour Date: Sat, 10 Apr 2021 15:24:20 +0200 Subject: [PATCH] feat: Adding ping of redis into healthcheck Signed-off-by: Vincent Boutour --- cmd/ketchup/api.go | 6 +++--- pkg/token/token.go | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/ketchup/api.go b/cmd/ketchup/api.go index 11932fd5..3e215388 100644 --- a/cmd/ketchup/api.go +++ b/cmd/ketchup/api.go @@ -93,7 +93,9 @@ func main() { } }() - healthApp := health.New(healthConfig, ketchupDb.Ping) + tokenApp := token.New(tokenConfig) + + healthApp := health.New(healthConfig, ketchupDb.Ping, tokenApp.Ping) authServiceApp, authMiddlewareApp := initAuth(ketchupDb) @@ -109,8 +111,6 @@ func main() { publicRendererApp, err := renderer.New(rendererConfig, content, ketchup.FuncMap) logger.Fatal(err) - tokenApp := token.New(tokenConfig) - notifierApp := notifier.New(notifierConfig, repositoryServiceApp, ketchupServiceApp, mailerApp) schedulerApp := scheduler.New(schedulerConfig, notifierApp) ketchupApp := ketchup.New(publicRendererApp, ketchupServiceApp, userServiceApp, repositoryServiceApp, tokenApp) diff --git a/pkg/token/token.go b/pkg/token/token.go index 96136440..297436aa 100644 --- a/pkg/token/token.go +++ b/pkg/token/token.go @@ -18,6 +18,7 @@ type App interface { Store(context.Context, string, time.Duration) (string, error) Load(context.Context, string) (string, error) Delete(context.Context, string) error + Ping() error } // Config of package @@ -53,6 +54,10 @@ func New(config Config) App { } } +func (a app) Ping() error { + return a.redisClient.Ping(context.Background()).Err() +} + func (a app) Store(ctx context.Context, value string, duration time.Duration) (string, error) { token := uuid()