From 85b0e002d6893476ccc4b13ecc36861ff0d79bc6 Mon Sep 17 00:00:00 2001 From: Snider Date: Fri, 6 Mar 2026 14:10:56 +0000 Subject: [PATCH] refactor: swap pkg/framework imports to pkg/core Co-Authored-By: Virgil --- global_test.go | 26 +++++++++++++------------- process_global.go | 4 ++-- runner_test.go | 8 ++++---- service.go | 18 +++++++++--------- service_test.go | 18 +++++++++--------- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/global_test.go b/global_test.go index 80a8158..3b0a2af 100644 --- a/global_test.go +++ b/global_test.go @@ -5,7 +5,7 @@ import ( "sync" "testing" - "forge.lthn.ai/core/go/pkg/framework" + "forge.lthn.ai/core/go/pkg/core" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -53,12 +53,12 @@ func TestGlobal_SetDefault(t *testing.T) { } }() - core, err := framework.New( - framework.WithName("process", NewService(Options{})), + core, err := core.New( + core.WithName("process", NewService(Options{})), ) require.NoError(t, err) - svc, err := framework.ServiceFor[*Service](core, "process") + svc, err := core.ServiceFor[*Service](core, "process") require.NoError(t, err) SetDefault(svc) @@ -81,12 +81,12 @@ func TestGlobal_ConcurrentDefault(t *testing.T) { } }() - core, err := framework.New( - framework.WithName("process", NewService(Options{})), + core, err := core.New( + core.WithName("process", NewService(Options{})), ) require.NoError(t, err) - svc, err := framework.ServiceFor[*Service](core, "process") + svc, err := core.ServiceFor[*Service](core, "process") require.NoError(t, err) SetDefault(svc) @@ -117,12 +117,12 @@ func TestGlobal_ConcurrentSetDefault(t *testing.T) { // Create multiple services var services []*Service for i := 0; i < 10; i++ { - core, err := framework.New( - framework.WithName("process", NewService(Options{})), + core, err := core.New( + core.WithName("process", NewService(Options{})), ) require.NoError(t, err) - svc, err := framework.ServiceFor[*Service](core, "process") + svc, err := core.ServiceFor[*Service](core, "process") require.NoError(t, err) services = append(services, svc) } @@ -161,12 +161,12 @@ func TestGlobal_ConcurrentOperations(t *testing.T) { } }() - core, err := framework.New( - framework.WithName("process", NewService(Options{})), + core, err := core.New( + core.WithName("process", NewService(Options{})), ) require.NoError(t, err) - svc, err := framework.ServiceFor[*Service](core, "process") + svc, err := core.ServiceFor[*Service](core, "process") require.NoError(t, err) SetDefault(svc) diff --git a/process_global.go b/process_global.go index deed860..f59157d 100644 --- a/process_global.go +++ b/process_global.go @@ -5,7 +5,7 @@ import ( "sync" "sync/atomic" - "forge.lthn.ai/core/go/pkg/framework" + "forge.lthn.ai/core/go/pkg/core" ) // Global default service (follows i18n pattern). @@ -32,7 +32,7 @@ func SetDefault(s *Service) { // Init initializes the default global service with a Core instance. // This is typically called during application startup. -func Init(c *framework.Core) error { +func Init(c *core.Core) error { defaultOnce.Do(func() { factory := NewService(Options{}) svc, err := factory(c) diff --git a/runner_test.go b/runner_test.go index 7d27f8c..7c3f354 100644 --- a/runner_test.go +++ b/runner_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "forge.lthn.ai/core/go/pkg/framework" + "forge.lthn.ai/core/go/pkg/core" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -12,12 +12,12 @@ import ( func newTestRunner(t *testing.T) *Runner { t.Helper() - core, err := framework.New( - framework.WithName("process", NewService(Options{})), + core, err := core.New( + core.WithName("process", NewService(Options{})), ) require.NoError(t, err) - svc, err := framework.ServiceFor[*Service](core, "process") + svc, err := core.ServiceFor[*Service](core, "process") require.NoError(t, err) return NewRunner(svc) diff --git a/service.go b/service.go index 405fac1..44ccfc6 100644 --- a/service.go +++ b/service.go @@ -11,7 +11,7 @@ import ( "sync/atomic" "time" - "forge.lthn.ai/core/go/pkg/framework" + "forge.lthn.ai/core/go/pkg/core" ) // Default buffer size for process output (1MB). @@ -26,7 +26,7 @@ var ( // Service manages process execution with Core IPC integration. type Service struct { - *framework.ServiceRuntime[Options] + *core.ServiceRuntime[Options] processes map[string]*Process mu sync.RWMutex @@ -43,16 +43,16 @@ type Options struct { // NewService creates a process service factory for Core registration. // -// core, _ := framework.New( -// framework.WithName("process", process.NewService(process.Options{})), +// core, _ := core.New( +// core.WithName("process", process.NewService(process.Options{})), // ) -func NewService(opts Options) func(*framework.Core) (any, error) { - return func(c *framework.Core) (any, error) { +func NewService(opts Options) func(*core.Core) (any, error) { + return func(c *core.Core) (any, error) { if opts.BufferSize == 0 { opts.BufferSize = DefaultBufferSize } svc := &Service{ - ServiceRuntime: framework.NewServiceRuntime(c, opts), + ServiceRuntime: core.NewServiceRuntime(c, opts), processes: make(map[string]*Process), bufSize: opts.BufferSize, } @@ -60,12 +60,12 @@ func NewService(opts Options) func(*framework.Core) (any, error) { } } -// OnStartup implements framework.Startable. +// OnStartup implements core.Startable. func (s *Service) OnStartup(ctx context.Context) error { return nil } -// OnShutdown implements framework.Stoppable. +// OnShutdown implements core.Stoppable. // Kills all running processes on shutdown. func (s *Service) OnShutdown(ctx context.Context) error { s.mu.RLock() diff --git a/service_test.go b/service_test.go index b72e3e2..b5ad3a1 100644 --- a/service_test.go +++ b/service_test.go @@ -7,20 +7,20 @@ import ( "testing" "time" - "forge.lthn.ai/core/go/pkg/framework" + "forge.lthn.ai/core/go/pkg/core" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -func newTestService(t *testing.T) (*Service, *framework.Core) { +func newTestService(t *testing.T) (*Service, *core.Core) { t.Helper() - core, err := framework.New( - framework.WithName("process", NewService(Options{BufferSize: 1024})), + core, err := core.New( + core.WithName("process", NewService(Options{BufferSize: 1024})), ) require.NoError(t, err) - svc, err := framework.ServiceFor[*Service](core, "process") + svc, err := core.ServiceFor[*Service](core, "process") require.NoError(t, err) return svc, core @@ -120,8 +120,8 @@ func TestService_Run(t *testing.T) { func TestService_Actions(t *testing.T) { t.Run("broadcasts events", func(t *testing.T) { - core, err := framework.New( - framework.WithName("process", NewService(Options{})), + core, err := core.New( + core.WithName("process", NewService(Options{})), ) require.NoError(t, err) @@ -130,7 +130,7 @@ func TestService_Actions(t *testing.T) { var exited []ActionProcessExited var mu sync.Mutex - core.RegisterAction(func(c *framework.Core, msg framework.Message) error { + core.RegisterAction(func(c *core.Core, msg core.Message) error { mu.Lock() defer mu.Unlock() switch m := msg.(type) { @@ -144,7 +144,7 @@ func TestService_Actions(t *testing.T) { return nil }) - svc, _ := framework.ServiceFor[*Service](core, "process") + svc, _ := core.ServiceFor[*Service](core, "process") proc, err := svc.Start(context.Background(), "echo", "test") require.NoError(t, err)