Skip to content

Commit

Permalink
feat: Adding ping of redis into healthcheck
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <bob@vibioh.fr>
  • Loading branch information
ViBiOh committed Apr 10, 2021
1 parent f609fa4 commit 18df8a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cmd/ketchup/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions pkg/token/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 18df8a3

Please sign in to comment.