fortify/internal/state/state.go
Ophestra Umiker b752ec4468
All checks were successful
Tests / Go tests (push) Successful in 1m12s
Nix / NixOS tests (push) Successful in 10m51s
fipc: export config struct
Also store full config as part of state.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-12-18 13:45:55 +09:00

39 lines
891 B
Go

package state
import (
"time"
"git.ophivana.moe/security/fortify/fipc"
)
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.
// Backend provided to f becomes invalid as soon as f returns.
Do(f func(b Backend)) (bool, error)
// Close releases any resources held by Store.
Close() error
}
// Backend provides access to the store
type Backend interface {
Save(state *State) error
Destroy(pid int) error
Load() ([]*State, error)
Len() (int, error)
}
// State is the on-disk format for a fortified process's state information
type State struct {
// fortify instance id
ID [16]byte `json:"instance"`
// child process PID value
PID int `json:"pid"`
// sealed app configuration
Config *fipc.Config `json:"config"`
// process start time
Time time.Time
}