Initial phase 1 baseline implementation
This commit is contained in:
parent
099c53badf
commit
077cf7601a
29 changed files with 1339 additions and 39 deletions
41
internal/application/system.go
Normal file
41
internal/application/system.go
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
package application
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type SystemRepository interface {
|
||||
DatabaseHealth(context.Context) error
|
||||
OwnerExists(context.Context) (bool, error)
|
||||
}
|
||||
|
||||
type SetupStatus struct {
|
||||
Initialized bool `json:"initialized"`
|
||||
Phase string `json:"phase"`
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
type SystemService struct {
|
||||
repository SystemRepository
|
||||
version string
|
||||
}
|
||||
|
||||
func NewSystemService(repository SystemRepository, version string) *SystemService {
|
||||
return &SystemService{repository: repository, version: version}
|
||||
}
|
||||
|
||||
func (s *SystemService) Readiness(ctx context.Context) error {
|
||||
if err := s.repository.DatabaseHealth(ctx); err != nil {
|
||||
return fmt.Errorf("database health: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SystemService) SetupStatus(ctx context.Context) (SetupStatus, error) {
|
||||
initialized, err := s.repository.OwnerExists(ctx)
|
||||
if err != nil {
|
||||
return SetupStatus{}, fmt.Errorf("read owner setup state: %w", err)
|
||||
}
|
||||
return SetupStatus{Initialized: initialized, Phase: "phase-1", Version: s.version}, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue