handler

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 7 Imported by: 46

Documentation

Overview

Package handler defines invocation-facing binder and handler abstractions plus capability keys shared by the unified engine. Concrete SQL and transport behavior belongs to providers outside this package.

Index

Constants

View Source
const (
	// DifferCapabilityKey exposes typed comparisons through scoped DI.
	DifferCapabilityKey = xhandler.DifferKey
	// LoggerCapabilityKey exposes the invocation logger through the narrow binder
	// lookup surface for internal runtime-owned DI.
	LoggerCapabilityKey = xhandler.LoggerKey
	// ValidatorCapabilityKey exposes the invocation validator through the narrow
	// binder lookup surface for internal runtime-owned DI.
	ValidatorCapabilityKey = xhandler.ValidatorKey
	// MessageBusCapabilityKey exposes the invocation message bus through the
	// narrow binder lookup surface for internal runtime-owned DI.
	MessageBusCapabilityKey = xhandler.MessageBusKey
	// ConnectorCapabilityKey identifies the explicitly granted named DB provider.
	ConnectorCapabilityKey = xhandler.ConnectorKey
	// RemoteMapperCapabilityKey selects the runtime-owned mapper through native DI.
	RemoteMapperCapabilityKey xhandler.ValueKey = "remote_mapper"
)
View Source
const (
	// TransactionSQLCapabilityKey identifies connector-scoped immediate SQL
	// execution through Datly's invocation-owned transaction unit.
	TransactionSQLCapabilityKey xhandler.ValueKey = "transactionSQL"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Binder

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

Binder is the xdatly handler facade over one Bindly invocation scope.

func NewBinder

func NewBinder(injector *bindly.Injector, input any) *Binder

func (*Binder) Bind

func (b *Binder) Bind(ctx context.Context, target any) error

func (*Binder) Lookup

func (b *Binder) Lookup(ctx context.Context, key xhandler.ValueKey) (any, bool, error)

type Handler

type Handler interface {
	Execute(ctx context.Context, invocation Invocation) (any, error)
}

type HandlerFunc

type HandlerFunc func(ctx context.Context, invocation Invocation) (any, error)

func (HandlerFunc) Execute

func (f HandlerFunc) Execute(ctx context.Context, invocation Invocation) (any, error)

type InputCapturer

type InputCapturer interface {
	CaptureInput(context.Context, any) (any, error)
}

InputCapturer is an opt-in pre-initialization adapter. The engine treats its result as opaque; generated/custom handlers own capture and interpretation.

type Invocation

type Invocation struct {
	Input    any
	Binder   xhandler.Binder
	Response xresponse.Writer
	// Snapshot is the opaque pre-initialization capture result. It is also
	// available to outcome finalizers when initialization failed before Execute.
	Snapshot any
}

Invocation is the canonical input, DI, and response surface passed to every runtime handler flavor after shared binding and input initialization.

type InvocationCapabilities

type InvocationCapabilities = xhandler.Capabilities

InvocationCapabilities groups DI-bindable runtime capabilities that handlers may need, but which should not expand the thin public session facade.

type MessageBusService

type MessageBusService = xhandler.MessageBus

type OutcomeFinalizer

type OutcomeFinalizer interface {
	FinalizeOutcome(context.Context, Invocation, any, xhandler.Outcome) error
}

OutcomeFinalizer is the opt-in bridge used by generic mutation adapters. It replaces output Finalizer/ErrorFinalizer/FinalizeMCP for that adapter only, and runs once after the owning root completes every database unit. Invocation may have a nil Binder and result may be nil after an early binding/init error. No MCP sampling hook is invoked. Publication must check CommitConfirmed().

type PreBindingTransaction

type PreBindingTransaction interface {
	RequiresPreBindingTransaction() bool
}

PreBindingTransaction requests that the engine start its managed data transaction before binding input views. Mutation Current/Previous and auxiliary reads can then share the same transaction as the queued writes. Read-only/custom handlers remain unaffected unless they opt in explicitly.

type TransactionSQL

type TransactionSQL interface {
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
}

TransactionSQL exposes immediate SQL execution inside Datly's managed invocation transaction. It deliberately does not expose Commit or Rollback.

type TransactionSQLProvider

type TransactionSQLProvider interface {
	Connector(ctx context.Context, name string) (TransactionSQL, error)
}

TransactionSQLProvider resolves a connector name to transaction-scoped SQL. Each connector maps to its own Datly database unit; this is not distributed transaction coordination across connectors.

type TypedHandler

type TypedHandler interface {
	Handler
	InputType() reflect.Type
	OutputType() reflect.Type
}

TypedHandler exposes the contract types of handlers assembled from Go shapes. Registration can use these without reflecting over handler methods.

type ValidationService

type ValidationService = xhandler.Validator

Directories

Path Synopsis
codec
structql
Package structql implements the built-in StructQL parameter codec.
Package structql implements the built-in StructQL parameter codec.
transfer
Package transfer implements the built-in transform codec from the original Datly transfer tags using the reusable datly/transform planner.
Package transfer implements the built-in transform codec from the original Datly transfer tags using the reusable datly/transform planner.
Package compiler converts canonical component parameters and Go input types into immutable Bindly plans and codec bindings.
Package compiler converts canonical component parameters and Go input types into immutable Bindly plans and codec bindings.
Package custom adapts typed user-defined Go handlers to the shared runtime handler contract.
Package custom adapts typed user-defined Go handlers to the shared runtime handler contract.
Package engine owns the common invocation path shared by runtime handler flavors: one Bindly scope, one input plan, and one lifecycle.
Package engine owns the common invocation path shared by runtime handler flavors: one Bindly scope, one input plan, and one lifecycle.
Package loaddata provides an ordinary component handler for typed AFS data.
Package loaddata provides an ordinary component handler for typed AFS data.
Package mutation adapts generated mutation programs to the canonical handler engine.
Package mutation adapts generated mutation programs to the canonical handler engine.
Package provider adapts runtime-owned values into Bindly providers.
Package provider adapts runtime-owned values into Bindly providers.
cache
Package cache adapts explicitly named caches to native Bindly injection.
Package cache adapts explicitly named caches to native Bindly injection.
clients
Package clients is the composition-root wiring for outbound client capabilities.
Package clients is the composition-root wiring for outbound client capabilities.
Package proxy provides an ordinary custom handler for explicitly configured HTTP forwarding.
Package proxy provides an ordinary custom handler for explicitly configured HTTP forwarding.
Package reader adapts a registered read execution to the unified handler engine without owning SQL plans, connections, caches, or mutable read state.
Package reader adapts a registered read execution to the unified handler engine without owning SQL plans, connections, caches, or mutable read state.
Package remote contains an ordinary remote component handler.
Package remote contains an ordinary remote component handler.
Package velty adapts cached typed Velty programs to the shared handler engine.
Package velty adapts cached typed Velty programs to the shared handler engine.
Package writer provides the metadata-driven built-in mutation handler.
Package writer provides the metadata-driven built-in mutation handler.

Jump to

Keyboard shortcuts

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