aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/app/app.go14
-rw-r--r--internal/app/app_linux.go17
-rw-r--r--internal/app/export_linux_test.go9
3 files changed, 14 insertions, 26 deletions
diff --git a/internal/app/app.go b/internal/app/app.go
index 506703c2..d59b145d 100644
--- a/internal/app/app.go
+++ b/internal/app/app.go
@@ -4,22 +4,8 @@ package app
import (
"syscall"
"time"
-
- "hakurei.app/hst"
- "hakurei.app/internal/app/state"
)
-type App interface {
- // ID returns a copy of [state.ID] held by App.
- ID() state.ID
-
- // Seal determines the outcome of config as a [SealedApp].
- // The value of config might be overwritten and must not be used again.
- Seal(config *hst.Config) (SealedApp, error)
-
- String() string
-}
-
type SealedApp interface {
// Run commits sealed system setup and starts the app process.
Run(rs *RunState) error
diff --git a/internal/app/app_linux.go b/internal/app/app_linux.go
index bdfc9eaf..eebfacdc 100644
--- a/internal/app/app_linux.go
+++ b/internal/app/app_linux.go
@@ -11,8 +11,8 @@ import (
"hakurei.app/internal/sys"
)
-func New(ctx context.Context, os sys.State) (App, error) {
- a := new(app)
+func New(ctx context.Context, os sys.State) (*App, error) {
+ a := new(App)
a.sys = os
a.ctx = ctx
@@ -23,7 +23,7 @@ func New(ctx context.Context, os sys.State) (App, error) {
return a, err
}
-func MustNew(ctx context.Context, os sys.State) App {
+func MustNew(ctx context.Context, os sys.State) *App {
a, err := New(ctx, os)
if err != nil {
log.Fatalf("cannot create app: %v", err)
@@ -31,7 +31,7 @@ func MustNew(ctx context.Context, os sys.State) App {
return a
}
-type app struct {
+type App struct {
id *stringPair[state.ID]
sys sys.State
ctx context.Context
@@ -40,9 +40,10 @@ type app struct {
mu sync.RWMutex
}
-func (a *app) ID() state.ID { a.mu.RLock(); defer a.mu.RUnlock(); return a.id.unwrap() }
+// ID returns a copy of [state.ID] held by App.
+func (a *App) ID() state.ID { a.mu.RLock(); defer a.mu.RUnlock(); return a.id.unwrap() }
-func (a *app) String() string {
+func (a *App) String() string {
if a == nil {
return "(invalid app)"
}
@@ -60,7 +61,9 @@ func (a *app) String() string {
return fmt.Sprintf("(unsealed app %s)", a.id)
}
-func (a *app) Seal(config *hst.Config) (SealedApp, error) {
+// Seal determines the outcome of [hst.Config] as a [SealedApp].
+// Values stored in and referred to by [hst.Config] might be overwritten and must not be used again.
+func (a *App) Seal(config *hst.Config) (SealedApp, error) {
a.mu.Lock()
defer a.mu.Unlock()
diff --git a/internal/app/export_linux_test.go b/internal/app/export_linux_test.go
index 73c9df9a..f7af527f 100644
--- a/internal/app/export_linux_test.go
+++ b/internal/app/export_linux_test.go
@@ -7,17 +7,16 @@ import (
"hakurei.app/system"
)
-func NewWithID(id state.ID, os sys.State) App {
- a := new(app)
+func NewWithID(id state.ID, os sys.State) *App {
+ a := new(App)
a.id = newID(&id)
a.sys = os
return a
}
-func AppIParams(a App, sa SealedApp) (*system.I, *container.Params) {
- v := a.(*app)
+func AppIParams(a *App, sa SealedApp) (*system.I, *container.Params) {
seal := sa.(*outcome)
- if v.outcome != seal || v.id != seal.id {
+ if a.outcome != seal || a.id != seal.id {
panic("broken app/outcome link")
}
return seal.sys, seal.container