watchrequest

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package watchrequest is the leeway-coded wire form of the watch-request payload on `fs.handle.{uuid}.watch`.

Vocabulary: three narrow terms (vdd.MembWatchPollFallback, vdd.MembWatchPollIntervalMs, vdd.MembWatchRecursive). All fields default to zero values; the broker-side defaults (auto-routing inotify/poller, 500ms tick, single-level watch) kick in when the wire carries zeros.

The legacy "empty payload yields zero WatchRequest" interop hook in `fsbroker.UnmarshalWatchRequest` survives the migration — callers that publish nil to use defaults stay wire-compatible.

Index

Constants

This section is empty.

Variables

View Source
var PackageProps = packageprops.Props{
	WASMWASI:         packageprops.WASMBlocked,
	WASMJS:           packageprops.WASMBlocked,
	WASMFreestanding: packageprops.WASMBlocked,
}

PackageProps records this package's curated properties (ADR-0080). Seeded by `wasmsurvey props generate`; curate by hand, then `wasmsurvey props verify`.

View Source
var WatchRequestActiveFields = sync.OnceValue(func() []int {
	active := map[string]bool{"bool": true, "i32Array": true}
	schema := cbdml.CreateSchemaFacts()
	out := make([]int, 0, 4+len(active)*8)
	for i, f := range schema.Fields() {
		name := f.Name
		switch {
		case strings.HasPrefix(name, "id:"),
			strings.HasPrefix(name, "ts:"),
			strings.HasPrefix(name, "lc:"):
			out = append(out, i)
		case strings.HasPrefix(name, "tv:"):
			rest := name[3:]
			colon := strings.IndexByte(rest, ':')
			if colon < 0 {
				continue
			}
			if active[rest[:colon]] {
				out = append(out, i)
			}
		}
	}
	return out
})

WatchRequestActiveFields is the column-index subset this kind populates in the runtime.facts Arrow schema. Lazily computed once via sync.OnceValue: scans cbdml.CreateSchemaFacts()'s tv:<section>:... field names against this kind's active sections plus the three plain prefixes (id:, ts:, lc:). Driven through RecordBuilder. SetActiveFields to skip per-row emit walks for unused columns.

View Source
var WatchRequestActiveSections = []int{1, 6}

WatchRequestActiveSections is the dml_cbor section-index subset this kind populates. Passed to InEntityFacts.SetActiveSections so the builder skips beginSection list-slot work for inactive sections.

Functions

func WatchRequestBuildEntities

func WatchRequestBuildEntities[
	BoolAttr WatchRequestBoolAttrI,
	BoolSec WatchRequestBoolSecI[BoolAttr, Ent],
	I32ArrayAttr WatchRequestI32ArrayAttrI,
	I32ArraySec WatchRequestI32ArraySecI[I32ArrayAttr, Ent],
	Ent any,
	DML WatchRequestEntityI[
		BoolAttr, BoolSec,
		I32ArrayAttr, I32ArraySec,
		Ent,
	],
](dml DML, c *WatchRequestColumns) (err error)

WatchRequestBuildEntities walks c row-by-row, drives dml's entity / section chain, and returns once every row has been committed. The dml argument's concrete type binds every type parameter via Go's type inference at the call site.

func WatchRequestFillFromArrow

func WatchRequestFillFromArrow[
	BoolAttrs WatchRequestBoolAttrsReadI,
	BoolMembs WatchRequestBoolMembsReadI,
	I32ArrayAttrs WatchRequestI32ArrayAttrsReadI,
	I32ArrayMembs WatchRequestI32ArrayMembsReadI,
](
	c *WatchRequestColumns,
	n int,
	idCol *array.Uint64,
	nkCol *array.Binary,
	tsCol *array.Timestamp,
	boolAttrs BoolAttrs,
	boolMembs BoolMembs,
	i32ArrayAttrs I32ArrayAttrs,
	i32ArrayMembs I32ArrayMembs,
) (err error)

WatchRequestFillFromArrow walks rec row-by-row and appends each entity's plain + tagged-section values into c. Plain columns enter as concrete Arrow accessors; per-section Attrs + Membs bind through type-parameter interfaces.

Types

type WatchRequest

type WatchRequest struct {
	FactId uint64 `lw:",id"`

	// NaturalKey is the entity natural key; the facts SetId is 2-arg.
	// These bus DTOs carry no separate key, so it stays the nil default.
	NaturalKey []byte `lw:",naturalKey"`

	// At is the event timestamp. time.Time matches the facts
	// SetTimestamp signature directly (strict 1:1); the leeway wire
	// truncates to u32 seconds, while the bus preserves full nanos.
	At time.Time `lw:",ts"`

	// PollFallback forces the poller backend regardless of the
	// underlying filesystem.
	PollFallback bool `lw:"watchPollFallback,bool"`

	// PollIntervalMs is the poller tick interval. Zero selects
	// default 500ms; values below 100ms clamp at the broker.
	PollIntervalMs int32 `lw:"watchPollIntervalMs,i32Array"`

	// Recursive enables subtree watching from the handle's root.
	Recursive bool `lw:"watchRecursive,bool"`
	// contains filtered or unexported fields
}

WatchRequest is the flat wire form of a watch request.

type WatchRequestBoolAttrI

type WatchRequestBoolAttrI interface {
	dmlruntime.InAttributeMembershipLowCardRefPI
	EndAttributeP()
}

WatchRequestBoolAttrI is the InAttr-side view of the bool section. P-variants only — every method returns void so no F-bounded `[Self]` parameter is needed.

type WatchRequestBoolAttrsReadI

type WatchRequestBoolAttrsReadI interface {
	GetAttrValueValue(entityIdx raruntime.EntityIdx, attrIdx raruntime.AttributeIdx) bool
	GetNumberOfAttributes(entityIdx raruntime.EntityIdx) int64
}

WatchRequestBoolAttrsReadI is the Attributes-side view of the bool section.

type WatchRequestBoolMembsReadI

type WatchRequestBoolMembsReadI interface {
	GetMembValueLowCardRef(entityIdx raruntime.EntityIdx, attrIdx raruntime.AttributeIdx) iter.Seq[uint64]
}

WatchRequestBoolMembsReadI is the Memberships-side view of the bool section.

type WatchRequestBoolSecI

type WatchRequestBoolSecI[Attr any, Ent any] interface {
	BeginAttribute(value bool) Attr
	EndSection() Ent
}

WatchRequestBoolSecI is the Section-side view: opens an attribute and closes the section. Attr and Ent are bound at the call site by inference.

type WatchRequestCodec

type WatchRequestCodec struct{}

WatchRequestCodec is the buscodec.CodecI bridge for WatchRequest. Encodes one row through dml_cbor; decodes via cborarrow.Convert + ra-Unmarshal + Row(0). Auto-registered in init() so callers using buscodec.Encode / Decode route through here instead of the CBOR fallback.

func (*WatchRequestCodec) ContentType

func (inst *WatchRequestCodec) ContentType() (ct string)

func (*WatchRequestCodec) Decode

func (inst *WatchRequestCodec) Decode(b []byte, v any) (err error)

func (*WatchRequestCodec) Encode

func (inst *WatchRequestCodec) Encode(v any) (b []byte, err error)

func (*WatchRequestCodec) Name

func (inst *WatchRequestCodec) Name() (n string)

type WatchRequestColumns

type WatchRequestColumns struct {
	FactId     []uint64
	NaturalKey [][]byte
	At         []time.Time

	PollFallback   []bool
	PollIntervalMs []int32
	Recursive      []bool
}

WatchRequestColumns is the SoA storage for batches of WatchRequest rows. All slices grow in lockstep — Len returns the row count.

func (*WatchRequestColumns) Append

func (c *WatchRequestColumns) Append(row WatchRequest)

Append pushes one AoS record into the SoA buffers.

Aliasing: slice and pointer fields (`[]T`, `*roaring.Bitmap`) are stored by reference, not copied. Callers must not mutate row.<F> after Append unless they want Marshal to read the mutation. Scalar fields (T, Option[T]) are copied by value.

func (*WatchRequestColumns) Len

func (c *WatchRequestColumns) Len() int

Len returns the number of rows currently in the batch.

func (*WatchRequestColumns) Marshal

func (c *WatchRequestColumns) Marshal(w io.Writer) (err error)

Marshal writes the SoA buffer to w as the sparse-CBOR wire format produced through factsschema/dml_cbor. Thin wrapper around WatchRequestBuildEntities — the per-row chain lives there and works against any leeway-DML class that structurally satisfies WatchRequestEntityI.

func (*WatchRequestColumns) Row

func (c *WatchRequestColumns) Row(i int) (row WatchRequest)

Row reconstructs entity i as an AoS WatchRequest record. Inverse of Append: slice / pointer fields are shared by reference (no defensive copy); scalar fields and Option[T] are copied.

func (*WatchRequestColumns) Unmarshal

func (c *WatchRequestColumns) Unmarshal(rec arrow.Record) (err error)

Unmarshal appends one row to c per entity in rec, projecting the runtime.facts columns through factsschema/ra. Thin wrapper around WatchRequestFillFromArrow — the per-row decode lives there.

type WatchRequestEntityI

type WatchRequestEntityI[
	BoolAttr WatchRequestBoolAttrI,
	BoolSec WatchRequestBoolSecI[BoolAttr, Ent],
	I32ArrayAttr WatchRequestI32ArrayAttrI,
	I32ArraySec WatchRequestI32ArraySecI[I32ArrayAttr, Ent],
	Ent any,
] interface {
	BeginEntity() Ent
	SetId(id uint64, naturalKey []byte) Ent
	SetTimestamp(ts time.Time) Ent
	GetSectionBool() BoolSec
	GetSectionI32Array() I32ArraySec
	CommitEntity() (err error)
}

WatchRequestEntityI lists exactly the entity-level methods WatchRequest uses. Type parameters compose the per-section Attr + Sec interfaces; Ent is the entity type itself (return type of BeginEntity / SetId / SetTimestamp / SetLifecycle — usually the DML pointer).

type WatchRequestI32ArrayAttrI

type WatchRequestI32ArrayAttrI interface {
	dmlruntime.InAttributeMembershipLowCardRefPI
	EndAttributeP()
}

WatchRequestI32ArrayAttrI is the InAttr-side view of the i32Array section. P-variants only — every method returns void so no F-bounded `[Self]` parameter is needed.

type WatchRequestI32ArrayAttrsReadI

type WatchRequestI32ArrayAttrsReadI interface {
	GetAttrValueSingleOrDefault(entityIdx raruntime.EntityIdx, attrIdx raruntime.AttributeIdx) int32
	GetNumberOfAttributes(entityIdx raruntime.EntityIdx) int64
}

WatchRequestI32ArrayAttrsReadI is the Attributes-side view of the i32Array section.

type WatchRequestI32ArrayMembsReadI

type WatchRequestI32ArrayMembsReadI interface {
	GetMembValueLowCardRef(entityIdx raruntime.EntityIdx, attrIdx raruntime.AttributeIdx) iter.Seq[uint64]
}

WatchRequestI32ArrayMembsReadI is the Memberships-side view of the i32Array section.

type WatchRequestI32ArraySecI

type WatchRequestI32ArraySecI[Attr any, Ent any] interface {
	BeginAttributeSingle(value int32) Attr
	EndSection() Ent
}

WatchRequestI32ArraySecI is the Section-side view: opens an attribute and closes the section. Attr and Ent are bound at the call site by inference.

Jump to

Keyboard shortcuts

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