CAT-RD8: minio asks the assigner's seat-holders once and follows its events, no reads, no cache on a timer

This commit is contained in:
2026-11-04 12:06:34 +01:00
parent 40e1e087e5
commit 3e3294cd47
6 changed files with 41 additions and 68 deletions
+9 -39
View File
@@ -9,7 +9,6 @@ import (
"os"
"path/filepath"
"strings"
"sync"
"time"
stdio "git.novox.be/novox/mesh-sdk/go"
@@ -21,7 +20,6 @@ import (
const (
DefaultSeconds = 300
MaxSeconds = 600
holdersFor = 60 * time.Second
)
// storeConfig is the store as this machine reaches it. The file is rendered by the mesh from files/object-store.json
@@ -60,41 +58,18 @@ func linkKeyID(bucket string) string {
type server struct {
configPath, linksDir, receives string
now func() time.Time
// seats reads the placement seat's state of who holds which seat, every key; a test replaces it.
// seats is the picture of the placement seat's state of who holds which seat, every key: asked of the assigner once
// and followed by its events (ADR 0615); a test replaces it.
seats func() (map[string][]byte, error)
mu sync.Mutex
keys map[string][]byte // seat-holders, as read
readAt time.Time
haveSet bool
}
func newServer(config, links, receives string) (*server, error) {
func newServer(config, links, receives string, seats func() (map[string][]byte, error)) (*server, error) {
for word, v := range map[string]string{ConfigWord: config, LinksWord: links, ReceivesWord: receives} {
if strings.TrimSpace(v) == "" {
return nil, fmt.Errorf("%s is not given: the manifest names it", word)
}
}
return &server{configPath: config, linksDir: links, receives: receives, now: time.Now, seats: askSeats}, nil
}
func askSeats() (map[string][]byte, error) {
state := stdio.State(delivery.SeatHoldersRead)
names, err := state.Keys()
if err != nil {
return nil, err
}
keys := map[string][]byte{}
for _, k := range names {
e, err := state.Get(k)
if err != nil {
return nil, err
}
if e != nil {
keys[k] = e.Value
}
}
return keys, nil
return &server{configPath: config, linksDir: links, receives: receives, now: time.Now, seats: seats}, nil
}
// link answers one ask.
@@ -266,18 +241,13 @@ func has(list []string, v string) bool {
}
// holds says whether node.module holds the seat, from the placement seat's state of who holds which seat (novox/hq ADR
// 0571 clause 4), read at most once a minute. A read that failed is not cached: the next ask reads again.
// 0571 clause 4), from the picture the assigner's first view and events keep. No first view yet is refused, saying so.
func (s *server) holds(seat, node, module string) (bool, error) {
s.mu.Lock()
defer s.mu.Unlock()
if !s.haveSet || s.now().Sub(s.readAt) >= holdersFor {
keys, err := s.seats()
if err != nil {
return false, err
}
s.keys, s.readAt, s.haveSet = keys, s.now(), true
keys, err := s.seats()
if err != nil {
return false, err
}
holders, err := delivery.HoldersOf(s.keys, seat, node)
holders, err := delivery.HoldersOf(keys, seat, node)
if err != nil {
return false, err
}