Skip to content

Commit

Permalink
feat: add readiness healthzer
Browse files Browse the repository at this point in the history
  • Loading branch information
franklinkim committed Mar 27, 2024
1 parent 1617ebb commit 71dfd39
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
@@ -1,5 +1,5 @@
-include .makerc
.DEFAULT_GOAL:=help
-include .makerc

# --- Targets -----------------------------------------------------------------

Expand Down
10 changes: 6 additions & 4 deletions cmd/http.go
Expand Up @@ -58,13 +58,15 @@ func NewHTTPCommand() *cobra.Command {
repo.WithPoll(pollFlag(v)),
)

// start initial update and handle error
svr.AddStartupHealthzers(healthz.NewHealthzerFn(func(ctx context.Context) error {
isLoadedHealtherFn := healthz.NewHealthzerFn(func(ctx context.Context) error {
if !r.Loaded() {
return errors.New("repo not ready yet")
return errors.New("repo not loaded yet")
}
return nil
}))
})
// start initial update and handle error
svr.AddStartupHealthzers(isLoadedHealtherFn)
svr.AddReadinessHealthzers(isLoadedHealtherFn)

svr.AddServices(
service.NewGoRoutine(l, "repo", func(ctx context.Context, l *zap.Logger) error {
Expand Down

0 comments on commit 71dfd39

Please sign in to comment.