watchreply

package
v0.0.21 Latest Latest
Warning

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

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

Documentation

Overview

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

Vocabulary:

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 `boxer code analysis golang wasmsurvey props generate`; curate by hand. The same group's `props verify` reconciles it.

View Source
var WatchReplyActiveFields = sync.OnceValue(func() []int {
	active := map[string]bool{"bool": true, "stringArray": true, "symbol": true, "textArray": 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
})

WatchReplyActiveFields is the column-index subset this kind populates in the boxer.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 WatchReplyActiveSections = []int{1, 9, 10, 12}

WatchReplyActiveSections 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 WatchReplyAddSections added in v0.0.17

func WatchReplyAddSections[
	BoolAttr WatchReplyBoolAttrI,
	BoolSec WatchReplyBoolSecI[BoolAttr, Ent],
	StringArrayAttr WatchReplyStringArrayAttrI,
	StringArraySec WatchReplyStringArraySecI[StringArrayAttr, Ent],
	SymbolAttr WatchReplySymbolAttrI,
	SymbolSec WatchReplySymbolSecI[SymbolAttr, Ent],
	TextArrayAttr WatchReplyTextArrayAttrI,
	TextArraySec WatchReplyTextArraySecI[TextArrayAttr, Ent],
	Ent any,
	DML WatchReplyEntityI[
		BoolAttr, BoolSec,
		StringArrayAttr, StringArraySec,
		SymbolAttr, SymbolSec,
		TextArrayAttr, TextArraySec,
		Ent,
	],
](dml DML, row WatchReply) (err error)

WatchReplyAddSections contributes this kind's tagged sections to the OPEN entity on dml — the BuildEntities body without the entity frame. The caller owns BeginEntity / plain setters / CommitEntity.

func WatchReplyBuildEntities

func WatchReplyBuildEntities[
	BoolAttr WatchReplyBoolAttrI,
	BoolSec WatchReplyBoolSecI[BoolAttr, Ent],
	StringArrayAttr WatchReplyStringArrayAttrI,
	StringArraySec WatchReplyStringArraySecI[StringArrayAttr, Ent],
	SymbolAttr WatchReplySymbolAttrI,
	SymbolSec WatchReplySymbolSecI[SymbolAttr, Ent],
	TextArrayAttr WatchReplyTextArrayAttrI,
	TextArraySec WatchReplyTextArraySecI[TextArrayAttr, Ent],
	Ent any,
	DML WatchReplyEntityI[
		BoolAttr, BoolSec,
		StringArrayAttr, StringArraySec,
		SymbolAttr, SymbolSec,
		TextArrayAttr, TextArraySec,
		Ent,
	],
](dml DML, c *WatchReplyColumns) (err error)

WatchReplyBuildEntities 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 WatchReplyEmitSectionBool added in v0.0.20

func WatchReplyEmitSectionBool[
	BoolAttr WatchReplyBoolAttrI,
	BoolSec WatchReplyBoolSecI[BoolAttr, Ent],
	Ent any,
](boolSec BoolSec, row WatchReply) (err error)

WatchReplyEmitSectionBool writes this kind's bool attributes into an ALREADY-OPEN section frame, and does not close it. The caller owns the frame: one kind's AddSections, or a builder deferring the close until every component that shares the section has written.

func WatchReplyEmitSectionStringArray added in v0.0.20

func WatchReplyEmitSectionStringArray[
	StringArrayAttr WatchReplyStringArrayAttrI,
	StringArraySec WatchReplyStringArraySecI[StringArrayAttr, Ent],
	Ent any,
](stringArraySec StringArraySec, row WatchReply) (err error)

WatchReplyEmitSectionStringArray writes this kind's stringArray attributes into an ALREADY-OPEN section frame, and does not close it. The caller owns the frame: one kind's AddSections, or a builder deferring the close until every component that shares the section has written.

func WatchReplyEmitSectionSymbol added in v0.0.20

func WatchReplyEmitSectionSymbol[
	SymbolAttr WatchReplySymbolAttrI,
	SymbolSec WatchReplySymbolSecI[SymbolAttr, Ent],
	Ent any,
](symbolSec SymbolSec, row WatchReply) (err error)

WatchReplyEmitSectionSymbol writes this kind's symbol attributes into an ALREADY-OPEN section frame, and does not close it. The caller owns the frame: one kind's AddSections, or a builder deferring the close until every component that shares the section has written.

func WatchReplyEmitSectionTextArray added in v0.0.20

func WatchReplyEmitSectionTextArray[
	TextArrayAttr WatchReplyTextArrayAttrI,
	TextArraySec WatchReplyTextArraySecI[TextArrayAttr, Ent],
	Ent any,
](textArraySec TextArraySec, row WatchReply) (err error)

WatchReplyEmitSectionTextArray writes this kind's textArray attributes into an ALREADY-OPEN section frame, and does not close it. The caller owns the frame: one kind's AddSections, or a builder deferring the close until every component that shares the section has written.

func WatchReplyFillFromArrow

func WatchReplyFillFromArrow[
	BoolAttrs WatchReplyBoolAttrsReadI,
	BoolMembs WatchReplyBoolMembsReadI,
	StringArrayAttrs WatchReplyStringArrayAttrsReadI,
	StringArrayMembs WatchReplyStringArrayMembsReadI,
	SymbolAttrs WatchReplySymbolAttrsReadI,
	SymbolMembs WatchReplySymbolMembsReadI,
	TextArrayAttrs WatchReplyTextArrayAttrsReadI,
	TextArrayMembs WatchReplyTextArrayMembsReadI,
](
	c *WatchReplyColumns,
	n int,
	idCol *array.Uint64,
	nkCol *array.Binary,
	tsCol *array.Timestamp,
	boolAttrs BoolAttrs,
	boolMembs BoolMembs,
	stringArrayAttrs StringArrayAttrs,
	stringArrayMembs StringArrayMembs,
	symbolAttrs SymbolAttrs,
	symbolMembs SymbolMembs,
	textArrayAttrs TextArrayAttrs,
	textArrayMembs TextArrayMembs,
) (err error)

WatchReplyFillFromArrow 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 WatchReply

type WatchReply 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"`

	// Started signals whether the watch actually started.
	Started bool `lw:"watchStarted,bool"`

	// EventSubject is the subject events publish to on success.
	EventSubject string `lw:"watchEventSubject,stringArray"`

	// Backend names the watcher implementation that was selected.
	Backend string `lw:"watchBackend,symbol"`

	// Reason carries the failure rationale (empty on success).
	Reason string `lw:"reason,textArray"`
	// contains filtered or unexported fields
}

WatchReply is the flat wire form of a watch reply.

func WatchReplyReadRow added in v0.0.17

func WatchReplyReadRow[
	BoolAttrs WatchReplyBoolAttrsReadI,
	BoolMembs WatchReplyBoolMembsReadI,
	StringArrayAttrs WatchReplyStringArrayAttrsReadI,
	StringArrayMembs WatchReplyStringArrayMembsReadI,
	SymbolAttrs WatchReplySymbolAttrsReadI,
	SymbolMembs WatchReplySymbolMembsReadI,
	TextArrayAttrs WatchReplyTextArrayAttrsReadI,
	TextArrayMembs WatchReplyTextArrayMembsReadI,
](
	i int,
	boolAttrs BoolAttrs,
	boolMembs BoolMembs,
	stringArrayAttrs StringArrayAttrs,
	stringArrayMembs StringArrayMembs,
	symbolAttrs SymbolAttrs,
	symbolMembs SymbolMembs,
	textArrayAttrs TextArrayAttrs,
	textArrayMembs TextArrayMembs,
) (row WatchReply, present bool, err error)

WatchReplyReadRow reads row i as one optional WatchReply component: presence- gated (a row carrying none of the kind's memberships yields present=false), membership-matched. A slot carrying more attributes than this kind's shape admits is an error, for every shape including containers. Plain- bound fields stay zero — the caller owns the envelope. The Attrs/Membs readers bind by type inference at the call site, as with FillFromArrow.

type WatchReplyBoolAttrI

type WatchReplyBoolAttrI interface {
	dmlruntime.InAttributeMembershipLowCardRefPI
	EndAttributeP()
}

WatchReplyBoolAttrI 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 WatchReplyBoolAttrsReadI

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

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

type WatchReplyBoolMembsReadI

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

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

type WatchReplyBoolSecI

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

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

type WatchReplyCodec

type WatchReplyCodec struct{}

WatchReplyCodec is the buscodec.CodecI bridge for WatchReply. 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 (*WatchReplyCodec) ContentType

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

func (*WatchReplyCodec) Decode

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

func (*WatchReplyCodec) Encode

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

func (*WatchReplyCodec) Name

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

type WatchReplyColumns

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

	Started      []bool
	EventSubject []string
	Backend      []string
	Reason       []string
}

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

func (*WatchReplyColumns) Append

func (c *WatchReplyColumns) Append(row WatchReply)

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 (*WatchReplyColumns) Len

func (c *WatchReplyColumns) Len() int

Len returns the number of rows currently in the batch.

func (*WatchReplyColumns) Marshal

func (c *WatchReplyColumns) 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 WatchReplyBuildEntities — the per-row chain lives there and works against any leeway-DML class that structurally satisfies WatchReplyEntityI.

func (*WatchReplyColumns) Row

func (c *WatchReplyColumns) Row(i int) (row WatchReply)

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

func (*WatchReplyColumns) Unmarshal

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

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

type WatchReplyEntityI

type WatchReplyEntityI[
	BoolAttr WatchReplyBoolAttrI,
	BoolSec WatchReplyBoolSecI[BoolAttr, Ent],
	StringArrayAttr WatchReplyStringArrayAttrI,
	StringArraySec WatchReplyStringArraySecI[StringArrayAttr, Ent],
	SymbolAttr WatchReplySymbolAttrI,
	SymbolSec WatchReplySymbolSecI[SymbolAttr, Ent],
	TextArrayAttr WatchReplyTextArrayAttrI,
	TextArraySec WatchReplyTextArraySecI[TextArrayAttr, Ent],
	Ent any,
] interface {
	BeginEntity() Ent
	SetId(id uint64, naturalKey []byte) Ent
	SetTimestamp(ts time.Time) Ent
	GetSectionBool() BoolSec
	GetSectionStringArray() StringArraySec
	GetSectionSymbol() SymbolSec
	GetSectionTextArray() TextArraySec
	CommitEntity() (err error)
}

WatchReplyEntityI is the entity-builder surface WatchReplyAddSections drives. It always lists the per-section getters; the entity-frame methods (BeginEntity / plain setters / CommitEntity) are added only for the full codec's BuildEntities. AddSections stacks sections onto a frame the caller already owns, so it needs none of them — which lets a store drive it with a builder whose frame control is unexported (ADR-0100 SD6). Ent is the builder pointer.

type WatchReplyStringArrayAttrI

type WatchReplyStringArrayAttrI interface {
	dmlruntime.InAttributeMembershipLowCardRefPI
	EndAttributeP()
}

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

type WatchReplyStringArrayAttrsReadI

type WatchReplyStringArrayAttrsReadI interface {
	GetAttrValueSingle(entityIdx raruntime.EntityIdx, attrIdx raruntime.AttributeIdx) (string, error)
	GetNumberOfAttributes(entityIdx raruntime.EntityIdx) int64
}

WatchReplyStringArrayAttrsReadI is the Attributes-side view of the stringArray section.

type WatchReplyStringArrayMembsReadI

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

WatchReplyStringArrayMembsReadI is the Memberships-side view of the stringArray section.

type WatchReplyStringArraySecI

type WatchReplyStringArraySecI[Attr any, Ent any] interface {
	BeginAttributeSingle(value string) Attr
	EndSection() Ent
}

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

type WatchReplySymbolAttrI

type WatchReplySymbolAttrI interface {
	dmlruntime.InAttributeMembershipLowCardRefPI
	EndAttributeP()
}

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

type WatchReplySymbolAttrsReadI

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

WatchReplySymbolAttrsReadI is the Attributes-side view of the symbol section.

type WatchReplySymbolMembsReadI

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

WatchReplySymbolMembsReadI is the Memberships-side view of the symbol section.

type WatchReplySymbolSecI

type WatchReplySymbolSecI[Attr any, Ent any] interface {
	BeginAttribute(value string) Attr
	EndSection() Ent
}

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

type WatchReplyTextArrayAttrI

type WatchReplyTextArrayAttrI interface {
	dmlruntime.InAttributeMembershipLowCardRefPI
	EndAttributeP()
}

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

type WatchReplyTextArrayAttrsReadI

type WatchReplyTextArrayAttrsReadI interface {
	GetAttrValueSingle(entityIdx raruntime.EntityIdx, attrIdx raruntime.AttributeIdx) (string, error)
	GetNumberOfAttributes(entityIdx raruntime.EntityIdx) int64
}

WatchReplyTextArrayAttrsReadI is the Attributes-side view of the textArray section.

type WatchReplyTextArrayMembsReadI

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

WatchReplyTextArrayMembsReadI is the Memberships-side view of the textArray section.

type WatchReplyTextArraySecI

type WatchReplyTextArraySecI[Attr any, Ent any] interface {
	BeginAttributeSingle(value string) Attr
	EndSection() Ent
}

WatchReplyTextArraySecI 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