velty

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Template string
}

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.

func (*DML) Delete

func (d *DML) Delete(tableName string, value interface{}) (string, error)

func (*DML) Execute

func (d *DML) Execute(statement string, args ...interface{}) (string, error)

func (*DML) Insert

func (d *DML) Insert(tableName string, value interface{}) (string, error)

func (*DML) Update

func (d *DML) Update(tableName string, value interface{}) (string, error)

type Differ

type Differ struct {
	// contains filtered or unexported fields
}

Differ adapts the scoped comparison capability to authored Velty calls.

func (*Differ) Diff

func (d *Differ) Diff(from, to any) (*xdiffer.ChangeLog, error)

Diff retains the original Velty differ's set-marker filtering policy.

type Handler

type Handler[I any, O any] struct {
	// contains filtered or unexported fields
}

func New

func New[I any, O any](config Config) (*Handler[I, O], error)

func (*Handler[I, O]) CaptureInput

func (h *Handler[I, O]) CaptureInput(ctx context.Context, value any) (any, error)

CaptureInput implements the engine's opt-in pre-initialization adapter.

func (*Handler[I, O]) Execute

func (h *Handler[I, O]) Execute(ctx context.Context, invocation rhandler.Invocation) (any, error)

func (*Handler[I, O]) InputType

func (h *Handler[I, O]) InputType() reflect.Type

func (*Handler[I, O]) OutputType

func (h *Handler[I, O]) OutputType() reflect.Type

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.

func (*Index) Has

func (i *Index) Has(name string, record any) (bool, error)

Has reports whether the ordered key fields of record exist in the named current index. Its lookup path contains no reflection or field discovery.

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func (*Logger) Debug

func (l *Logger) Debug(message string) string

func (*Logger) Error

func (l *Logger) Error(message string) string

func (*Logger) Info

func (l *Logger) Info(message string) string

func (*Logger) Warn

func (l *Logger) Warn(message string) string

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 Sequencer

type Sequencer struct {
	// contains filtered or unexported fields
}

func (*Sequencer) Allocate

func (s *Sequencer) Allocate(tableName string, dest interface{}, selector string) (string, error)

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

func (*Validator) Check

func (v *Validator) Check(value interface{}) (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 (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)

func (*WriteHooks) Require

func (w *WriteHooks) Require(value any, field, relation string) (string, error)

func (*WriteHooks) Value

func (w *WriteHooks) Value(path string, indexes ...int) (any, error)

Jump to

Keyboard shortcuts

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