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
|
/coverage.txt
|
||||||
bin/
|
bin/
|
||||||
tasks
|
tasks
|
||||||
|
/core
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package framework
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"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.
|
// 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 {
|
func (c *Core) ServiceShutdown(ctx context.Context) error {
|
||||||
var agg error
|
var agg error
|
||||||
if err := c.ACTION(ActionServiceShutdown{}); err != nil {
|
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.
|
// 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 {
|
func App() any {
|
||||||
if instance == nil {
|
if instance == nil {
|
||||||
panic("framework.App() called before framework.Setup() was successfully initialized")
|
panic("core.App() called before core.SetInstance()")
|
||||||
}
|
}
|
||||||
return instance.App
|
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.
|
// Config returns the registered Config service.
|
||||||
func (c *Core) Config() Config {
|
func (c *Core) Config() Config {
|
||||||
cfg := MustServiceFor[Config](c, "config")
|
cfg := MustServiceFor[Config](c, "config")
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package framework
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package framework
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package framework
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"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
|
// It allows for wrapping errors with contextual information, making it easier to
|
||||||
// trace the origin of an error and provide meaningful feedback.
|
// trace the origin of an error and provide meaningful feedback.
|
||||||
//
|
//
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
// that is more informative than a raw stack trace.
|
// that is more informative than a raw stack trace.
|
||||||
// - Consistent error handling: Encourages a uniform approach to error
|
// - Consistent error handling: Encourages a uniform approach to error
|
||||||
// handling across the entire codebase.
|
// handling across the entire codebase.
|
||||||
package framework
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package framework
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package framework
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package framework
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"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
|
// This is the most flexible way to create a new Runtime, as it allows for
|
||||||
// the registration of any number of services.
|
// the registration of any number of services.
|
||||||
func NewWithFactories(app any, factories map[string]ServiceFactory) (*Runtime, error) {
|
func NewWithFactories(app any, factories map[string]ServiceFactory) (*Runtime, error) {
|
||||||
services := make(map[string]any)
|
|
||||||
coreOpts := []Option{
|
coreOpts := []Option{
|
||||||
WithApp(app),
|
WithApp(app),
|
||||||
}
|
}
|
||||||
|
|
@ -66,7 +65,6 @@ func NewWithFactories(app any, factories map[string]ServiceFactory) (*Runtime, e
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to create service %s: %w", name, err)
|
return nil, fmt.Errorf("failed to create service %s: %w", name, err)
|
||||||
}
|
}
|
||||||
services[name] = svc
|
|
||||||
svcCopy := svc
|
svcCopy := svc
|
||||||
coreOpts = append(coreOpts, WithName(name, func(c *Core) (any, error) { return svcCopy, nil }))
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Type Assertions ---
|
return &Runtime{
|
||||||
|
|
||||||
rt := &Runtime{
|
|
||||||
app: app,
|
app: app,
|
||||||
Core: coreInstance,
|
Core: coreInstance,
|
||||||
}
|
}, nil
|
||||||
|
|
||||||
return rt, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRuntime creates and wires together all application services.
|
// 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)
|
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.
|
// This is where the Core's shutdown lifecycle is initiated.
|
||||||
func (r *Runtime) ServiceShutdown(ctx context.Context) {
|
func (r *Runtime) ServiceShutdown(ctx context.Context) {
|
||||||
if r.Core != nil {
|
if r.Core != nil {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package framework
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package framework
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
package framework
|
package framework
|
||||||
|
|
||||||
import (
|
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
|
// Re-export core types for cleaner imports
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue