diff options
| author | Ophestra Umiker <cat@ophivana.moe> | 2024-12-19 21:36:17 +0900 |
|---|---|---|
| committer | Ophestra Umiker <cat@ophivana.moe> | 2024-12-19 21:36:17 +0900 |
| commit | eae3034260b3abbb8da1deeddfef135b36eeb390 (patch) | |
| tree | a3dbc5d679a1137018ccec0886c68853e679b7bb /internal/state/state.go | |
| parent | 5ea7333431942780c79c02a990682e44b6834ed6 (diff) | |
state: expose aids and use instance id as key
Fortify state store instances was specific to aids due to outdated design decisions carried over from the ego rewrite. That no longer makes sense in the current application, so the interface now enables a single store object to manage all transient state.
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'internal/state/state.go')
| -rw-r--r-- | internal/state/state.go | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/internal/state/state.go b/internal/state/state.go index cf345aad..ccc44b11 100644 --- a/internal/state/state.go +++ b/internal/state/state.go @@ -6,21 +6,27 @@ import ( "git.ophivana.moe/security/fortify/fst" ) +type Entries map[fst.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. - // Backend provided to f becomes invalid as soon as f returns. - Do(f func(b Backend)) (bool, error) + // Cursor provided to f becomes invalid as soon as f returns. + Do(aid int, f func(c Cursor)) (ok bool, err error) + + // List queries the store and returns a list of aids known to the store. + // Note that some or all returned aids might not have any active apps. + List() (aids []int, err error) // Close releases any resources held by Store. Close() error } -// Backend provides access to the store -type Backend interface { +// Cursor provides access to the store +type Cursor interface { Save(state *State) error - Destroy(pid int) error - Load() ([]*State, error) + Destroy(id fst.ID) error + Load() (Entries, error) Len() (int, error) } |
