-
Notifications
You must be signed in to change notification settings - Fork 0
/
observer.go
27 lines (22 loc) · 870 Bytes
/
observer.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
package http
import (
"github.com/alexfalkowski/go-health/server"
"github.com/alexfalkowski/go-service/health/transport/http"
"github.com/alexfalkowski/migrieren/migrate"
)
// NewHealthObserver for HTTP.
func NewHealthObserver(healthServer *server.Server, migrate *migrate.Config) *http.HealthObserver {
names := make([]string, len(migrate.Databases))
for i, d := range migrate.Databases {
names[i] = d.Name
}
return &http.HealthObserver{Observer: healthServer.Observe(names...)}
}
// NewLivenessObserver for HTTP.
func NewLivenessObserver(healthServer *server.Server) *http.LivenessObserver {
return &http.LivenessObserver{Observer: healthServer.Observe("noop")}
}
// NewReadinessObserver for HTTP.
func NewReadinessObserver(healthServer *server.Server) *http.ReadinessObserver {
return &http.ReadinessObserver{Observer: healthServer.Observe("noop")}
}