aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/app/state/state.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-10-23 22:51:10 +0900
committerOphestra <cat@gensokyo.uk>2025-10-23 22:59:02 +0900
commitdd94818f20c7a37bdd7c6129551759db1b09b65e (patch)
tree1ea7c94b3f6aec92f037a3e58dc343c3b00cd5a2 /internal/app/state/state.go
parent0fd357e7f64ec029489bbbcc7935005a26cb9a13 (diff)
hst/instance: define instance state
This is now part of the hst API. This change also improves identifier generation and serialisation. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/app/state/state.go')
-rw-r--r--internal/app/state/state.go22
1 files changed, 3 insertions, 19 deletions
diff --git a/internal/app/state/state.go b/internal/app/state/state.go
index b8d8d255..ef783bfb 100644
--- a/internal/app/state/state.go
+++ b/internal/app/state/state.go
@@ -3,7 +3,6 @@ package state
import (
"errors"
- "time"
"hakurei.app/hst"
)
@@ -11,8 +10,6 @@ import (
// ErrNoConfig is returned by [Cursor] when used with a nil [hst.Config].
var ErrNoConfig = errors.New("state does not contain config")
-type Entries map[ID]*State
-
type Store interface {
// Do calls f exactly once and ensures store exclusivity until f returns.
// Returns whether f is called and any errors during the locking process.
@@ -29,21 +26,8 @@ type Store interface {
// Cursor provides access to the store of an identity.
type Cursor interface {
- Save(state *State) error
- Destroy(id ID) error
- Load() (Entries, error)
+ Save(state *hst.State) error
+ Destroy(id hst.ID) error
+ Load() (map[hst.ID]*hst.State, error)
Len() (int, error)
}
-
-// State is the on-disk state of a container instance.
-type State struct {
- // Unique instance id, generated by internal/app.
- ID ID `json:"instance"`
- // Shim process pid. This runs as the target user.
- PID int `json:"pid"`
- // Configuration value used to start the container.
- Config *hst.Config `json:"config"`
-
- // Exact point in time that the shim process was created.
- Time time.Time `json:"time"`
-}