note

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Overview

Package note owns the general reading surface — every route a reader reaches that is not one of the dedicated faces. Register mounts eleven of them: Home, one rendered note, one folder, the maps mode page, the folders mode page, the whole-vault health page, a vault file's raw bytes, the freshness poll a page keeps open on the note it is showing, the excerpt a hover card shows of the note under the reader's pointer, the language switch every page's footer posts to, and the catch-all that answers a path the vault has nothing at. The last is deliberately last: it exists so no request reaches the router's own fallback, which answers in English and offers nowhere to go.

A vault file with no dedicated reader is shown here too, as an honest stand-in page rather than as something this package pretends to render. Status mutation remains in internal/status.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler serves reading pages from one rooted vault capability and its coherently published snapshots.

func New

func New(d *Sources) *Handler

New wires the reading feature. It defensively copies the startup-owned record so later field reassignment by the caller cannot rewire a live handler. Every required reference and function must be non-nil: a wiring bug fails here, not on the first request three calls deep inside show(). A fail-closed write face still provides a closed status.Authority.

func (*Handler) Register

func (h *Handler) Register(mux *http.ServeMux)

Register mounts the feature's routes. The bare "GET /" is the last pattern any request can match, and it exists so that none of them reaches the router's own fallback, which answers in English and offers nowhere to go.

type Sources added in v0.2.0

type Sources struct {
	Source   *vaultfs.Reader
	Status   func() status.Authority
	Snapshot func() *snapshot.Generation
	// ObservedStatus is a closure over the write package's read of the note's
	// own status line. The rest of the page comes from a scan that lags the
	// folder by a couple of seconds, which a body and a link graph can afford
	// and an adjudication state cannot: the reader arrives here straight from a
	// write, and a status that lags is one they have already changed.
	//
	// It takes the request's context because the read queues behind the write
	// face's own lock, which one flip can hold across two synchronizations.
	ObservedStatus func(ctx context.Context, rel string) (string, error)
	// ConsumeReceipt is a closure over the write face's attestation that it
	// recently flipped the note at rel out of status from, spending the
	// attestation when it answers true. The transition receipt renders only
	// on that answer, so the page's sentence about a change is backed by the
	// one component that performed it rather than by whatever a URL claims.
	ConsumeReceipt func(rel, from string) bool
	Log            *slog.Logger
}

Sources names the authorities one reading request draws on, and the log the routes report an operational fault to. Snapshot is one closure because a request must read the atomic pointer once and derive its navigation and counts from that coherent value. Status captures one immutable lifecycle view for the request. Source changes affect the next request; a write still revalidates current authority under the lifecycle lock.

Jump to

Keyboard shortcuts

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