-
Notifications
You must be signed in to change notification settings - Fork 1
/
registrations.go
38 lines (32 loc) · 1.12 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
package health
import (
"github.com/alexfalkowski/go-health/checker"
"github.com/alexfalkowski/go-health/server"
"github.com/alexfalkowski/go-service/health"
"github.com/alexfalkowski/go-service/transport/http"
khealth "github.com/alexfalkowski/konfig/health"
"github.com/alexfalkowski/konfig/source"
"github.com/hashicorp/vault/api"
"go.uber.org/fx"
)
// RegistrationsParams for health.
type RegistrationsParams struct {
fx.In
HTTP *http.Config
Source *source.Config
Vault *api.Config
Health *khealth.Config
}
// NewRegistrations for health.
func NewRegistrations(params RegistrationsParams) health.Registrations {
client := http.NewClient(http.ClientParams{Config: params.HTTP})
registrations := health.Registrations{
server.NewRegistration("noop", params.Health.Duration, checker.NewNoopChecker()),
server.NewRegistration("vault", params.Health.Duration, checker.NewHTTPChecker(params.Vault.Address, client)),
}
s := params.Source
if s.IsGit() {
registrations = append(registrations, server.NewRegistration("git", params.Health.Duration, checker.NewHTTPChecker(s.Git.URL, client)))
}
return registrations
}