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>
This commit is contained in:
2025-10-23 22:51:10 +09:00
parent 0fd357e7f6
commit dd94818f20
19 changed files with 261 additions and 227 deletions

View File

@@ -3,6 +3,8 @@ package state
import (
"errors"
"maps"
"hakurei.app/hst"
)
var (
@@ -14,20 +16,22 @@ Joiner is the interface that wraps the Join method.
The Join function uses Joiner if available.
*/
type Joiner interface{ Join() (Entries, error) }
type Joiner interface {
Join() (map[hst.ID]*hst.State, error)
}
// Join returns joined state entries of all active aids.
func Join(s Store) (Entries, error) {
// Join returns joined state entries of all active identities.
func Join(s Store) (map[hst.ID]*hst.State, error) {
if j, ok := s.(Joiner); ok {
return j.Join()
}
var (
aids []int
entries = make(Entries)
entries = make(map[hst.ID]*hst.State)
el int
res Entries
res map[hst.ID]*hst.State
loadErr error
)