All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m19s
Test / Hakurei (push) Successful in 3m15s
Test / Sandbox (race detector) (push) Successful in 3m50s
Test / Hpkg (push) Successful in 3m40s
Test / Hakurei (race detector) (push) Successful in 5m15s
Test / Flake checks (push) Successful in 1m36s
A lot of these comments are quite old and have not been updated to reflect changes. Signed-off-by: Ophestra <cat@gensokyo.uk>
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
// Package app implements high-level hakurei container behaviour.
|
|
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
|
|
}
|
|
|
|
// RunState stores the outcome of a call to [SealedApp.Run].
|
|
type RunState struct {
|
|
// Time is the exact point in time where the process was created.
|
|
// Location must be set to UTC.
|
|
//
|
|
// Time is nil if no process was ever created.
|
|
Time *time.Time
|
|
// RevertErr is stored by the deferred revert call.
|
|
RevertErr error
|
|
// WaitErr is the generic error value created by the standard library.
|
|
WaitErr error
|
|
|
|
syscall.WaitStatus
|
|
}
|
|
|
|
// SetStart stores the current time in [RunState] once.
|
|
func (rs *RunState) SetStart() {
|
|
if rs.Time != nil {
|
|
panic("attempted to store time twice")
|
|
}
|
|
now := time.Now().UTC()
|
|
rs.Time = &now
|
|
}
|