control

package
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ControlSize = 4096       // 1 page
	Magic       = 0x4C455943 // 'LEYC'
	// Version 3 is the current control-block protocol (ley-line-open
	// v0.20.1+, ley-line-open-49a1ef): the layout is v2's, identity is the
	// BLAKE3 `current_root` of the arena payload, and the word at offset 8 is
	// a seqlock sequence, odd while a writer is changing the payload and even
	// when it is whole. v2 wrote the payload and then bumped the word once,
	// so a reader could not tell a publish in flight from a finished one.
	// Any other version is rejected with a descriptive error, so
	// cross-version mismatches fail loudly (mache-3451a1).
	Version = 3
)

Variables

This section is empty.

Functions

func IsZeroRoot added in v0.8.0

func IsZeroRoot(root [32]byte) bool

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.

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, or the zero sentinel `[32]byte{}` when no snapshot has been published yet. The root is always one some publish wrote in full. The consistency is per call: a following GetArenaPath is its own snapshot and may reflect a later publish.

func (*Controller) SetArena

func (c *Controller) SetArena(path string, size uint64) error

SetArena points the control block at a new arena without changing `current_root`: a re-advertisement, which polling readers (who compare roots) do not treat as new content.

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 publishes a new arena and the BLAKE3 root of its payload. A reader sees either the previous (path, size, root) or this one, never a mixture.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL