state: store config in separate gob stream
All checks were successful
Build / Create distribution (push) Successful in 1m37s
Test / Run NixOS test (push) Successful in 3m38s

This enables early serialisation of config.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-01-21 12:10:58 +09:00
parent fa0616b274
commit dfcdc5ce20
7 changed files with 135 additions and 55 deletions

View File

@@ -1,11 +1,15 @@
package state
import (
"errors"
"io"
"time"
"git.gensokyo.uk/security/fortify/fst"
)
var ErrNoConfig = errors.New("state does not contain config")
type Entries map[fst.ID]*State
type Store interface {
@@ -24,13 +28,13 @@ type Store interface {
// Cursor provides access to the store
type Cursor interface {
Save(state *State) error
Save(state *State, configWriter io.WriterTo) error
Destroy(id fst.ID) error
Load() (Entries, error)
Len() (int, error)
}
// State is the on-disk format for a fortified process's state information
// State is a fortify process's state
type State struct {
// fortify instance id
ID fst.ID `json:"instance"`
@@ -40,5 +44,5 @@ type State struct {
Config *fst.Config `json:"config"`
// process start time
Time time.Time
Time time.Time `json:"time"`
}