refactor(framework): rename package from framework to core
Aligns package name with directory structure (pkg/framework/core). Fixes doc comment in e.go and adds core binary to gitignore. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c21a271dcf
commit
f4da42d095
12 changed files with 26 additions and 24 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -14,5 +14,6 @@ coverage.html
|
|||
/coverage.txt
|
||||
bin/
|
||||
tasks
|
||||
/core
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package framework
|
||||
package core
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -150,7 +150,7 @@ func (c *Core) ServiceStartup(ctx context.Context, options any) error {
|
|||
}
|
||||
|
||||
// ServiceShutdown is the entry point for the Core service's shutdown lifecycle.
|
||||
// It is called by Wails when the application shuts down.
|
||||
// It is called by the GUI runtime when the application shuts down.
|
||||
func (c *Core) ServiceShutdown(ctx context.Context) error {
|
||||
var agg error
|
||||
if err := c.ACTION(ActionServiceShutdown{}); err != nil {
|
||||
|
|
@ -262,14 +262,21 @@ func MustServiceFor[T any](c *Core, name string) T {
|
|||
}
|
||||
|
||||
// App returns the global application instance.
|
||||
// It panics if the Core has not been initialized.
|
||||
// It panics if the Core has not been initialized via SetInstance.
|
||||
// This is typically used by GUI runtimes that need global access.
|
||||
func App() any {
|
||||
if instance == nil {
|
||||
panic("framework.App() called before framework.Setup() was successfully initialized")
|
||||
panic("core.App() called before core.SetInstance()")
|
||||
}
|
||||
return instance.App
|
||||
}
|
||||
|
||||
// SetInstance sets the global Core instance for App() access.
|
||||
// This is typically called by GUI runtimes during initialization.
|
||||
func SetInstance(c *Core) {
|
||||
instance = c
|
||||
}
|
||||
|
||||
// Config returns the registered Config service.
|
||||
func (c *Core) Config() Config {
|
||||
cfg := MustServiceFor[Config](c, "config")
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package framework
|
||||
package core
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package framework
|
||||
package core
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package framework
|
||||
package core
|
||||
|
||||
import (
|
||||
"embed"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Package e provides a standardized error handling mechanism for the Core library.
|
||||
// Package core provides a standardized error handling mechanism for the Core library.
|
||||
// It allows for wrapping errors with contextual information, making it easier to
|
||||
// trace the origin of an error and provide meaningful feedback.
|
||||
//
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
// that is more informative than a raw stack trace.
|
||||
// - Consistent error handling: Encourages a uniform approach to error
|
||||
// handling across the entire codebase.
|
||||
package framework
|
||||
package core
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package framework
|
||||
package core
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package framework
|
||||
package core
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package framework
|
||||
package core
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -49,7 +49,6 @@ type ServiceFactory func() (any, error)
|
|||
// This is the most flexible way to create a new Runtime, as it allows for
|
||||
// the registration of any number of services.
|
||||
func NewWithFactories(app any, factories map[string]ServiceFactory) (*Runtime, error) {
|
||||
services := make(map[string]any)
|
||||
coreOpts := []Option{
|
||||
WithApp(app),
|
||||
}
|
||||
|
|
@ -66,7 +65,6 @@ func NewWithFactories(app any, factories map[string]ServiceFactory) (*Runtime, e
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create service %s: %w", name, err)
|
||||
}
|
||||
services[name] = svc
|
||||
svcCopy := svc
|
||||
coreOpts = append(coreOpts, WithName(name, func(c *Core) (any, error) { return svcCopy, nil }))
|
||||
}
|
||||
|
|
@ -76,14 +74,10 @@ func NewWithFactories(app any, factories map[string]ServiceFactory) (*Runtime, e
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// --- Type Assertions ---
|
||||
|
||||
rt := &Runtime{
|
||||
return &Runtime{
|
||||
app: app,
|
||||
Core: coreInstance,
|
||||
}
|
||||
|
||||
return rt, nil
|
||||
}, nil
|
||||
}
|
||||
|
||||
// NewRuntime creates and wires together all application services.
|
||||
|
|
@ -104,7 +98,7 @@ func (r *Runtime) ServiceStartup(ctx context.Context, options any) {
|
|||
r.Core.ServiceStartup(ctx, options)
|
||||
}
|
||||
|
||||
// ServiceShutdown is called by Wails at application shutdown.
|
||||
// ServiceShutdown is called by the GUI runtime at application shutdown.
|
||||
// This is where the Core's shutdown lifecycle is initiated.
|
||||
func (r *Runtime) ServiceShutdown(ctx context.Context) {
|
||||
if r.Core != nil {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package framework
|
||||
package core
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package framework
|
||||
package core
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
package framework
|
||||
|
||||
import (
|
||||
core "github.com/host-uk/core/pkg/framework/core"
|
||||
"github.com/host-uk/core/pkg/framework/core"
|
||||
)
|
||||
|
||||
// Re-export core types for cleaner imports
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue