Documentation
¶
Overview ¶
Package velty adapts cached typed Velty programs to the shared handler engine. Binding, DI scope, transaction completion, and output finalization remain engine-owned.
Index ¶
- type Config
- type Context
- type DML
- type Differ
- type Handler
- func (h *Handler[I, O]) CaptureInput(ctx context.Context, value any) (any, error)
- func (h *Handler[I, O]) Execute(ctx context.Context, invocation rhandler.Invocation) (any, error)
- func (h *Handler[I, O]) InputType() reflect.Type
- func (h *Handler[I, O]) OutputType() reflect.Type
- func (h *Handler[I, O]) WithInputCapture(capture func(context.Context, *I) (any, error)) *Handler[I, O]
- type Index
- type Logger
- type MessageBus
- type Sequencer
- type Validator
- type WriteHooks
- func (w *WriteHooks) Entity(path string, indexes ...int) (string, error)
- func (w *WriteHooks) Link(child, parent any, childField, parentField string) (string, error)
- func (w *WriteHooks) Mark(path, field string, indexes ...int) (string, error)
- func (w *WriteHooks) Present(path string, indexes ...int) (bool, error)
- func (w *WriteHooks) Relation(path, holderName string, indexes ...int) (string, error)
- func (w *WriteHooks) Require(value any, field, relation string) (string, error)
- func (w *WriteHooks) Value(path string, indexes ...int) (any, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
Differ *Differ `velty:"names=differ"`
DML *DML `velty:"names=dml"`
Index *Index `velty:"names=index"`
Sequencer *Sequencer `velty:"names=sequencer"`
Validator *Validator `velty:"names=validator"`
MessageBus *MessageBus `velty:"names=messageBus"`
Logger *Logger `velty:"names=logger"`
WriteHooks *WriteHooks `velty:"names=writeHooks"`
}
Context is the explicit Velty capability surface. The compiled program exposes typed input separately as $Input/$input and individual fields.
type DML ¶
type DML struct {
// contains filtered or unexported fields
}
DML exposes buffered sqlx operations to templates. Flush and transaction completion intentionally remain engine-owned.
type Differ ¶
type Differ struct {
// contains filtered or unexported fields
}
Differ adapts the scoped comparison capability to authored Velty calls.
type Handler ¶
func (*Handler[I, O]) CaptureInput ¶
CaptureInput implements the engine's opt-in pre-initialization adapter.
func (*Handler[I, O]) OutputType ¶
func (*Handler[I, O]) WithInputCapture ¶
func (h *Handler[I, O]) WithInputCapture(capture func(context.Context, *I) (any, error)) *Handler[I, O]
WithInputCapture returns a configured copy sharing only the immutable compiled program. The callback must capture detached invocation-local state without mutating the input and must be safe for concurrent calls. A nil callback disables capture on the returned copy, leaving the receiver unchanged.
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index owns named presence indexes for one Velty handler invocation.
func (*Index) Build ¶
func (i *Index) Build(name string, current any, input any, recordPath string, fieldPairs ...string) (string, error)
Build compiles ordered current/record field pairs and indexes the current typed slice. Reflection is confined to this one setup call; Has uses the compiled record accessor for every traversal lookup.
type MessageBus ¶
type MessageBus struct {
// contains filtered or unexported fields
}
func (*MessageBus) Publish ¶
func (b *MessageBus) Publish(destination string, value interface{}) (string, error)
func (*MessageBus) PublishWithSubject ¶
func (b *MessageBus) PublishWithSubject(destination string, value interface{}, subject string) (string, error)
type WriteHooks ¶
type WriteHooks struct {
// contains filtered or unexported fields
}
WriteHooks adapts generated optional entity/relation hooks to one invocation. Static paths are resolved by x/shape; indexes retain actual slice addresses.
func (*WriteHooks) Entity ¶
func (w *WriteHooks) Entity(path string, indexes ...int) (string, error)
func (*WriteHooks) Link ¶
func (w *WriteHooks) Link(child, parent any, childField, parentField string) (string, error)
Link preserves the exact parent field address when a relation key changes pointer cardinality. Both records come from Value, never foreach copies.
func (*WriteHooks) Mark ¶
func (w *WriteHooks) Mark(path, field string, indexes ...int) (string, error)
func (*WriteHooks) Present ¶
func (w *WriteHooks) Present(path string, indexes ...int) (bool, error)
func (*WriteHooks) Relation ¶
func (w *WriteHooks) Relation(path, holderName string, indexes ...int) (string, error)