From 06a5fe9ac8bd43f8343b235aec2c1b671a457933 Mon Sep 17 00:00:00 2001 From: Virgil Date: Fri, 3 Apr 2026 07:16:16 +0000 Subject: [PATCH] feat(core-service): satisfy core lifecycle contract Co-Authored-By: Virgil --- core_service.go | 12 ++++++++++-- core_service_test.go | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/core_service.go b/core_service.go index 0620f0f..642d42d 100644 --- a/core_service.go +++ b/core_service.go @@ -21,6 +21,9 @@ type CoreService struct { hookInstalled bool } +var _ core.Startable = (*CoreService)(nil) +var _ core.Stoppable = (*CoreService)(nil) + func (s *CoreService) wrapped() *Service { if s == nil { return nil @@ -135,11 +138,16 @@ func NewCoreService(opts ServiceOptions) func(*core.Core) (any, error) { } // OnStartup initialises the i18n service. -func (s *CoreService) OnStartup(_ context.Context) error { +func (s *CoreService) OnStartup(_ context.Context) core.Result { if svc := s.wrapped(); svc != nil && svc.Mode() == ModeCollect { s.ensureMissingKeyCollector() } - return nil + return core.Result{OK: true} +} + +// OnShutdown finalises the i18n service. +func (s *CoreService) OnShutdown(_ context.Context) core.Result { + return core.Result{OK: true} } func (s *CoreService) ensureMissingKeyCollector() { diff --git a/core_service_test.go b/core_service_test.go index f54c49f..74042c6 100644 --- a/core_service_test.go +++ b/core_service_test.go @@ -40,7 +40,8 @@ func TestCoreServiceNilSafe(t *testing.T) { }) assert.Nil(t, defaultService.Load()) - assert.NoError(t, svc.OnStartup(nil)) + assert.Equal(t, core.Result{OK: true}, svc.OnStartup(nil)) + assert.Equal(t, core.Result{OK: true}, svc.OnShutdown(nil)) svc.SetMode(ModeCollect) svc.SetFallback("fr") svc.SetFormality(FormalityFormal)