Rename HealthcheckParams and HealthcheckResponse to avoid stuttering
This commit is contained in:
@@ -13,8 +13,8 @@ import (
|
|||||||
"sneak.berlin/go/pixa/internal/logger"
|
"sneak.berlin/go/pixa/internal/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HealthcheckParams defines dependencies for Healthcheck.
|
// Params defines dependencies for Healthcheck.
|
||||||
type HealthcheckParams struct {
|
type Params struct {
|
||||||
fx.In
|
fx.In
|
||||||
Globals *globals.Globals
|
Globals *globals.Globals
|
||||||
Config *config.Config
|
Config *config.Config
|
||||||
@@ -31,7 +31,7 @@ type Healthcheck struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new Healthcheck instance.
|
// New creates a new Healthcheck instance.
|
||||||
func New(lc fx.Lifecycle, params HealthcheckParams) (*Healthcheck, error) {
|
func New(lc fx.Lifecycle, params Params) (*Healthcheck, error) {
|
||||||
s := &Healthcheck{
|
s := &Healthcheck{
|
||||||
log: params.Logger.Get(),
|
log: params.Logger.Get(),
|
||||||
globals: params.Globals,
|
globals: params.Globals,
|
||||||
@@ -52,8 +52,8 @@ func New(lc fx.Lifecycle, params HealthcheckParams) (*Healthcheck, error) {
|
|||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// HealthcheckResponse is the JSON response for health checks.
|
// Response is the JSON response for health checks.
|
||||||
type HealthcheckResponse struct {
|
type Response struct {
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Now string `json:"now"`
|
Now string `json:"now"`
|
||||||
UptimeSeconds int64 `json:"uptime_seconds"`
|
UptimeSeconds int64 `json:"uptime_seconds"`
|
||||||
@@ -68,8 +68,8 @@ func (s *Healthcheck) uptime() time.Duration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Healthcheck returns the current health status.
|
// Healthcheck returns the current health status.
|
||||||
func (s *Healthcheck) Healthcheck() *HealthcheckResponse {
|
func (s *Healthcheck) Healthcheck() *Response {
|
||||||
resp := &HealthcheckResponse{
|
resp := &Response{
|
||||||
Status: "ok",
|
Status: "ok",
|
||||||
Now: time.Now().UTC().Format(time.RFC3339Nano),
|
Now: time.Now().UTC().Format(time.RFC3339Nano),
|
||||||
UptimeSeconds: int64(s.uptime().Seconds()),
|
UptimeSeconds: int64(s.uptime().Seconds()),
|
||||||
|
|||||||
Reference in New Issue
Block a user