From dd94818f20c7a37bdd7c6129551759db1b09b65e Mon Sep 17 00:00:00 2001 From: Ophestra Date: Thu, 23 Oct 2025 22:51:10 +0900 Subject: 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 --- internal/app/state/state.go | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) (limited to 'internal/app/state/state.go') 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"` -} -- cgit v1.3.1