-
Notifications
You must be signed in to change notification settings - Fork 1
/
registrations.go
43 lines (37 loc) · 1.34 KB
/
registrations.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package health
import (
"github.com/alexfalkowski/go-health/checker"
"github.com/alexfalkowski/go-health/server"
"github.com/alexfalkowski/go-service/health"
schecker "github.com/alexfalkowski/go-service/health/checker"
"github.com/alexfalkowski/go-service/transport/http"
khealth "github.com/alexfalkowski/konfig/health"
"github.com/alexfalkowski/konfig/source"
"github.com/go-redis/redis/v8"
"github.com/hashicorp/vault/api"
"go.uber.org/fx"
"go.uber.org/zap"
)
// Params for health.
type Params struct {
fx.In
HTTP *http.Config
Source *source.Config
Redis *redis.Ring
Vault *api.Config
Logger *zap.Logger
Health *khealth.Config
}
// NewRegistrations for health.
func NewRegistrations(params Params) health.Registrations {
client := http.NewClient(params.HTTP, params.Logger)
registrations := health.Registrations{
server.NewRegistration("noop", params.Health.Duration, checker.NewNoopChecker()),
server.NewRegistration("redis", params.Health.Duration, schecker.NewRedisChecker(params.Redis, params.Health.Timeout)),
server.NewRegistration("vault", params.Health.Duration, checker.NewHTTPChecker(params.Vault.Address, client)),
}
if params.Source.IsGit() {
registrations = append(registrations, server.NewRegistration("git", params.Health.Duration, checker.NewHTTPChecker(params.Source.Git.URL, client)))
}
return registrations
}