model

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InputKindRequest      = "request"
	InputKindStreamID     = "streamID"
	InputKindSSE          = "sse"
	InputKindSessionToken = "sessionToken"
	InputKindSession      = "session"
	InputKindPath         = "path"
	InputKindQuery        = "query"
	InputKindSignals      = "signals"
	InputKindDispatch     = "dispatch"
	InputKindEvent        = "event"
)

InputKind constants identify handler input parameter kinds.

View Source
const (
	OutputKindBody           = "body"
	OutputKindHead           = "head"
	OutputKindRedirect       = "redirect"
	OutputKindRedirectStatus = "redirectStatus"
	OutputKindNewSession     = "newSession"
	OutputKindCloseSession   = "closeSession"
	OutputKindEnableBgStream = "enableBackgroundStreaming"
	OutputKindDisableRefresh = "disableRefreshAfterHidden"
	OutputKindErr            = "err"
)

OutputKind constants identify handler output return value kinds.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbstractPage

type AbstractPage struct {
	Expr     ast.Expr
	TypeName string

	Methods       []*Handler
	StreamOpen    *Handler
	StreamClose   *Handler
	EventHandlers []*EventHandler
	Embeds        []*AbstractPage
}

type App

type App struct {
	Fset    *token.FileSet
	PkgPath string
	Expr    ast.Expr

	PageIndex    *Page
	PageError404 *Page
	PageError500 *Page

	RecoverError        ast.Expr    // Nullable.
	GlobalHeadGenerator *GlobalHead // Nullable.

	Session *SessionType // Nullable.

	Pages   []*Page
	Events  []*Event
	Actions []*Handler // App-level POST/PUT/PATCH/DELETE actions.
}

type Event

type Event struct {
	Expr ast.Expr

	TypeName string
	Subject  string

	SubjectFields []SubjectField
}

func (*Event) HasSignalSubjectFields added in v0.7.0

func (e *Event) HasSignalSubjectFields() bool

HasSignalSubjectFields reports whether the event has any signal-scoped subject fields (fields with a signal:"..." tag).

func (*Event) HasSubjectFields added in v0.7.0

func (e *Event) HasSubjectFields() bool

HasSubjectFields reports whether the event has any subject fields.

func (*Event) HasSubjectUser added in v0.7.0

func (e *Event) HasSubjectUser() bool

HasSubjectUser reports whether the event has a SubjectUser field.

func (*Event) IsPrivate added in v0.7.0

func (e *Event) IsPrivate() bool

IsPrivate reports whether the event targets specific users (has a SubjectUser field).

func (*Event) IsSignalScoped added in v0.7.0

func (e *Event) IsSignalScoped() bool

IsSignalScoped reports whether the event uses signal-based subject routing (has at least one signal-tagged subject field).

type EventHandler

type EventHandler struct {
	Expr ast.Expr

	Name          string
	EventTypeName string

	InputEvent        *Input
	InputSSE          *Input
	InputStreamID     *Input
	InputSessionToken *Input
	InputSession      *Input
	OrderedInputs     []*Input // Inputs in user-defined order.

	OutputErr *Output
}
type GlobalHead struct {
	Expr              ast.Expr
	InputSession      bool
	InputSessionToken bool
}

type Handler

type Handler struct {
	Expr ast.Expr

	Name string

	HTTPMethod string
	Route      string

	InputRequest      *Input
	InputStreamID     *Input
	InputSSE          *Input
	InputSessionToken *Input
	InputSession      *Input
	InputPath         *Input
	InputQuery        *Input
	InputSignals      *Input
	InputDispatch     *InputDispatch
	OrderedInputs     []*Input // Inputs in user-defined order.

	OutputBody           *TemplComponent // templ.Component body (actions only)
	OutputRedirect       *Output
	OutputRedirectStatus *Output
	OutputNewSession     *Output
	OutputCloseSession   *Output
	OutputEnableBgStream *Output
	OutputDisableRefresh *Output
	OutputErr            *Output
	OrderedOutputs       []*Output // Outputs in user-defined order.
}

type HandlerGET

type HandlerGET struct {
	*Handler
	OutputBody *TemplComponent
	OutputHead *TemplComponent
}

type Input

type Input struct {
	Expr ast.Expr

	Kind string // InputKind constant.
	Name string
	Type Type
}

type InputDispatch

type InputDispatch struct {
	*Input
	EventTypeNames []string
}

type Output

type Output struct {
	Expr ast.Expr

	Kind string // OutputKind constant.
	Name string

	Type Type
}

type Page

type Page struct {
	Expr     ast.Expr
	TypeName string
	Route    string

	PageSpecialization PageSpecialization

	GET           *HandlerGET
	Actions       []*Handler
	StreamOpen    *Handler
	StreamClose   *Handler
	EventHandlers []*EventHandler
	Embeds        []*AbstractPage
}

type PageSpecialization

type PageSpecialization int8
const (
	PageTypeIndex PageSpecialization
	PageTypeError404
	PageTypeError500
)

type SessionType

type SessionType struct {
	Expr ast.Expr
}

type SubjectField added in v0.7.0

type SubjectField struct {
	FieldName  string // e.g. "SubjectUser"
	Name       string // e.g. "User" (suffix after "Subject")
	SignalName string // e.g. "instance_id" (from signal:"instance_id" tag)
	Singular   bool   // true when the field type is string (not []string)
}

SubjectField represents a Subject-prefixed field on an event type. The field name suffix (e.g. "User" from "SubjectUser") identifies the subject segment; values are appended to the NATS subject at dispatch time.

SignalName, when non-empty, marks the field as signal-scoped: the SSE stream handler reads this signal from the client and subscribes to the subject with the signal value appended. This enables per-instance event routing without authentication.

type TemplComponent

type TemplComponent struct {
	*Output
}

type Type

type Type struct {
	Resolved types.Type
	TypeExpr ast.Expr
}

Jump to

Keyboard shortcuts

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