{"modulePath":"github.com/viant/datly","version":"v1.1.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package handler\n\nPackage 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.\n\n## Constants\n\n```go\nconst (\n\t// DifferCapabilityKey exposes typed comparisons through scoped DI.\n\tDifferCapabilityKey = xhandler.DifferKey\n\t// LoggerCapabilityKey exposes the invocation logger through the narrow binder\n\t// lookup surface for internal runtime-owned DI.\n\tLoggerCapabilityKey = xhandler.LoggerKey\n\t// ValidatorCapabilityKey exposes the invocation validator through the narrow\n\t// binder lookup surface for internal runtime-owned DI.\n\tValidatorCapabilityKey = xhandler.ValidatorKey\n\t// MessageBusCapabilityKey exposes the invocation message bus through the\n\t// narrow binder lookup surface for internal runtime-owned DI.\n\tMessageBusCapabilityKey = xhandler.MessageBusKey\n\t// ConnectorCapabilityKey identifies the explicitly granted named DB provider.\n\tConnectorCapabilityKey = xhandler.ConnectorKey\n\t// RemoteMapperCapabilityKey selects the runtime-owned mapper through native DI.\n\tRemoteMapperCapabilityKey xhandler.ValueKey = \"remote_mapper\"\n)\n```\n\n```go\nconst (\n\t// TransactionSQLCapabilityKey identifies connector-scoped immediate SQL\n\t// execution through Datly's invocation-owned transaction unit.\n\tTransactionSQLCapabilityKey xhandler.ValueKey = \"transactionSQL\"\n)\n```\n\n## Types\n\n```go\ntype Binder struct {\n\t// contains filtered or unexported fields\n}\n```\nBinder is the xdatly handler facade over one Bindly invocation scope.\n\n```go\nfunc NewBinder(injector *bindly.Injector, input any) *Binder\n```\n\n```go\nfunc (b *Binder) Bind(ctx context.Context, target any) error\n```\n\n```go\nfunc (b *Binder) Lookup(ctx context.Context, key xhandler.ValueKey) (any, bool, error)\n```\n\n```go\ntype Handler interface {\n\tExecute(ctx context.Context, invocation Invocation) (any, error)\n}\n```\n\n```go\ntype HandlerFunc func(ctx context.Context, invocation Invocation) (any, error)\n```\n\n```go\nfunc (f HandlerFunc) Execute(ctx context.Context, invocation Invocation) (any, error)\n```\n\n```go\ntype InputCapturer interface {\n\tCaptureInput(context.Context, any) (any, error)\n}\n```\nInputCapturer is an opt-in pre-initialization adapter. The engine treats its result as opaque; generated/custom handlers own capture and interpretation.\n\n```go\ntype Invocation struct {\n\tInput    any\n\tBinder   xhandler.Binder\n\tResponse xresponse.Writer\n\t// Snapshot is the opaque pre-initialization capture result. It is also\n\t// available to outcome finalizers when initialization failed before Execute.\n\tSnapshot any\n}\n```\nInvocation is the canonical input, DI, and response surface passed to every runtime handler flavor after shared binding and input initialization.\n\n```go\ntype InvocationCapabilities = xhandler.Capabilities\n```\nInvocationCapabilities groups DI-bindable runtime capabilities that handlers may need, but which should not expand the thin public session facade.\n\n```go\ntype MessageBusService = xhandler.MessageBus\n```\n\n```go\ntype OutcomeFinalizer interface {\n\tFinalizeOutcome(context.Context, Invocation, any, xhandler.Outcome) error\n}\n```\nOutcomeFinalizer 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().\n\n```go\ntype PreBindingTransaction interface {\n\tRequiresPreBindingTransaction() bool\n}\n```\nPreBindingTransaction 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.\n\n```go\ntype TransactionSQL interface {\n\tQueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)\n\tQueryRowContext(ctx context.Context, query string, args ...any) *sql.Row\n\tExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)\n}\n```\nTransactionSQL exposes immediate SQL execution inside Datly's managed invocation transaction. It deliberately does not expose Commit or Rollback.\n\n```go\ntype TransactionSQLProvider interface {\n\tConnector(ctx context.Context, name string) (TransactionSQL, error)\n}\n```\nTransactionSQLProvider 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.\n\n```go\ntype TypedHandler interface {\n\tHandler\n\tInputType() reflect.Type\n\tOutputType() reflect.Type\n}\n```\nTypedHandler exposes the contract types of handlers assembled from Go shapes. Registration can use these without reflecting over handler methods.\n\n```go\ntype ValidationService = xhandler.Validator\n```\n\n","path":"github.com/viant/datly/runtime/handler","name":"handler","synopsis":"Package handler defines invocation-facing binder and handler abstractions plus capability keys shared by the unified engine.","isRedistributable":true}
