exportsql

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package exportsql provides named SQL row sources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Definition

type Definition struct {
	Name          string
	Query         string
	Validate      func(params any) error
	ScopeInjector func(scope export.Scope, params any) (any, error)
}

Definition registers a named query.

type Executor

type Executor interface {
	Query(ctx context.Context, spec QuerySpec) (export.RowIterator, error)
}

Executor runs a named query and returns a row iterator.

type QuerySpec

type QuerySpec struct {
	Name    string
	Query   string
	Params  any
	Actor   export.Actor
	Scope   export.Scope
	Columns []export.Column
}

QuerySpec describes a named query execution.

type Registry

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

Registry stores named query definitions.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty registry.

func (*Registry) Register

func (r *Registry) Register(def Definition) error

Register adds a named query definition.

func (*Registry) Resolve

func (r *Registry) Resolve(name string) (Definition, bool)

Resolve returns a query definition by name.

type Source

type Source struct {
	Registry  *Registry
	Executor  Executor
	QueryName string
}

Source executes a named query with validated params.

func NewSource

func NewSource(reg *Registry, exec Executor, name string) *Source

NewSource creates a named query row source.

func (*Source) Open

Open validates params and executes the named query.

Jump to

Keyboard shortcuts

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