event

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package event provides the synchronous, in-process event bus used for Document lifecycle hooks (before_save, after_insert, etc.).

See TAD §2.5 and PRD §19.1 for the full specification. Implemented in Phase 4.

Index

Constants

View Source
const (
	EventBeforeValidate = "before_validate"
	EventAfterValidate  = "after_validate"
	EventBeforeInsert   = "before_insert"
	EventBeforeSave     = "before_save"
	EventAfterInsert    = "after_insert"
	EventAfterSave      = "after_save"
	EventBeforeUpdate   = "before_update"
	EventAfterUpdate    = "after_update"
	EventBeforeDelete   = "before_delete"
	EventAfterDelete    = "after_delete"
	EventOnSubmit       = "on_submit"
	EventOnCancel       = "on_cancel"
	EventOnWorkflow     = "on_workflow_transition"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

type Bus interface {
	// On registers handler h for (docType, eventName).
	// Handlers run in registration order (fail-fast, see Emit).
	On(docType, eventName string, h Handler)

	// Emit fires all registered handlers for (docType, eventName) in order.
	// If any handler returns a non-nil error, Emit stops and returns that error
	// immediately — subsequent handlers are not called (PRD §19.2 semantics).
	Emit(ctx context.Context, docType, eventName string, doc map[string]any) error
}

Bus is the in-process, synchronous event dispatcher for Document lifecycle events. See TAD §2.5.

Ordering: handlers for a (docType, eventName) pair run strictly in registration order and stop on the first error. The Bus has no notion of Applications, so cross-app ordering on a shared pair is whatever the wiring's registration order makes it. TAD §7.1 step 3's "a dependency's hooks run before its dependent's" is realized by installing Applications in dependency-resolved order (app.ResolveDAG) — each app's hooks are then registered before its dependent's. That is a registration-order guarantee, not one the Bus enforces (REVIEW-2026-08-12 finding 15).

func NewBus

func NewBus() Bus

NewBus creates a new, empty event Bus.

type Handler

type Handler func(ctx context.Context, doc map[string]any) error

Handler is a lifecycle callback. It receives the current document state as a map (column-keyed) and may return an error to abort the operation. See TAD §2.5 and PRD §19.1.

Jump to

Keyboard shortcuts

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