Documentation
¶
Index ¶
- Constants
- func IsZeroRoot(root [32]byte) bool
- type Controller
- func (c *Controller) Close() error
- func (c *Controller) GetArenaPath() string
- func (c *Controller) GetArenaSize() uint64
- func (c *Controller) GetCurrentRoot() [32]byte
- func (c *Controller) SetArena(path string, size uint64) error
- func (c *Controller) SetArenaWithRoot(path string, size uint64, root [32]byte) error
Constants ¶
const ( ControlSize = 4096 // 1 page Magic = 0x4C455943 // 'LEYC' // Version 2 is the current control-block layout: identity is the BLAKE3 // `current_root` of the arena payload. Old (v1) controllers — which // exposed a monotonic `generation` counter instead — are rejected with // a descriptive error so cross-version mismatches fail loudly. Version = 2 )
Variables ¶
This section is empty.
Functions ¶
func IsZeroRoot ¶ added in v0.8.0
IsZeroRoot reports whether root is the all-zero sentinel that indicates "no snapshot has been published yet."
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller manages the memory-mapped control file.
func OpenOrCreate ¶
func OpenOrCreate(path string) (*Controller, error)
OpenOrCreate opens or creates a control file at the given path. Rejects mismatched VERSION with a clear error so old mache binaries reading new control blocks (or vice versa) fail loudly rather than silently misinterpreting the layout.
func (*Controller) Close ¶
func (c *Controller) Close() error
Close unmaps and closes the control file.
func (*Controller) GetArenaPath ¶
func (c *Controller) GetArenaPath() string
GetArenaPath returns the path to the currently active arena.
The Acquire-load on the sync atom only fences the subsequent path-byte reads against publishes that have completed (sync bumped) by the time we load it; a writer that begins after the load and writes bytes before bumping sync can still produce a torn read here. End-to-end safety against torn reads relies on the BLAKE3 current_root check at the callsite — the path bytes alone are advisory. If a stronger guarantee is needed, the writer needs a seqlock-style protocol (bump-then-write- then-bump, with reader retry on odd / mismatched seq).
func (*Controller) GetArenaSize ¶ added in v0.8.0
func (c *Controller) GetArenaSize() uint64
GetArenaSize returns the size in bytes of the currently active arena file.
func (*Controller) GetCurrentRoot ¶ added in v0.8.0
func (c *Controller) GetCurrentRoot() [32]byte
GetCurrentRoot returns the BLAKE3 root hash of the arena payload that the writer most recently published. An Acquire-load on the private sync atom fences the subsequent root-byte reads against the writer's Release-store + write. The zero sentinel `[32]byte{}` means no snapshot has been published yet (fresh controller).
func (*Controller) SetArena ¶
func (c *Controller) SetArena(path string, size uint64) error
SetArena atomically updates the control block to point to a new arena without changing `current_root`. Bumps the private sync atom so readers fence and re-read path/size.
Use SetArenaWithRoot when publishing a new snapshot (i.e. when the payload bytes changed). Use SetArena when only the path/size moved but the root remains the previous value.
func (*Controller) SetArenaWithRoot ¶ added in v0.8.0
func (c *Controller) SetArenaWithRoot(path string, size uint64, root [32]byte) error
SetArenaWithRoot atomically publishes a new arena and the BLAKE3 root of its payload. Readers polling GetCurrentRoot observe a coherent (path, size, root) triple thanks to the Release-store fence on the sync atom.