Files
mesh-delivery/modules/mesh-delivery-assigner/internal/assignment/state.go
T
jschoubben 2a85e55d4e D1 (assigner): the assigner names its own states from its credential's module
Its buckets (the seat's states, wants, asks, puts, waits, findings, policies, pins, marks, first views) are functions of the module SetModule was told at its start (its credential's; the tools program's served-as), no longer constants of its name.

Builds: design 47 G A-296, §428

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-12 22:44:33 +01:00

44 lines
1.4 KiB
Go

package assignment
import (
"sync"
seat "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
)
var (
moduleMu sync.RWMutex
module string
)
// SetModule names the module the assigner runs as, from its credential's module, once at its start: its states are named
// after it, as every module state is (a bucket is `<module>_<state>`), and its manifest declares them. No code names the
// assigner's module (design 47 G A-296, §428).
func SetModule(m string) {
moduleMu.Lock()
defer moduleMu.Unlock()
module = m
}
// Module is the module the assigner runs as, as SetModule said at its start.
func Module() string {
moduleMu.RLock()
defer moduleMu.RUnlock()
return module
}
// The buckets of the seat's states, which only the holder writes (ADR 0567 §1).
func AssignmentsBucket() string { return Module() + "_" + seat.StateAssignments }
func ProposalsBucket() string { return Module() + "_" + seat.StateProposals }
func CandidatesBucket() string { return Module() + "_" + seat.StateCandidates }
func PulsesBucket() string { return Module() + "_" + seat.StatePulses }
func SeatHoldersBucket() string { return Module() + "_" + seat.StateSeatHolders }
const (
// AssignmentsHistory is the revisions the assignments bucket keeps per key: the bus's most (§6).
AssignmentsHistory = 64
// EventDays is how long the seat's events are kept: they ride the shared events stream on the seat's own subject
// (the seat's family, 7 days).
EventDays = 7
)