Files
GL/application/health/service.go
T

30 lines
529 B
Go

// Package health provides the service readiness use case.
package health
import "context"
type Database interface {
Ping(context.Context) error
}
type Status struct {
Serving bool
DatabaseReady bool
}
type Service struct {
database Database
}
func NewService(database Database) *Service {
return &Service{database: database}
}
func (s *Service) Check(ctx context.Context) Status {
status := Status{Serving: true}
if s.database != nil {
status.DatabaseReady = s.database.Ping(ctx) == nil
}
return status
}