fabric

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Copyright 2026 Teradata

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	FeatureFullTextSearch    = "full_text_search"
	FeatureJSONSupport       = "json_support"
	FeatureGeospatial        = "geospatial"
	FeatureWindowFunctions   = "window_functions"
	FeatureCTE               = "cte" // Common Table Expressions
	FeatureRecursiveCTE      = "recursive_cte"
	FeatureMaterializedViews = "materialized_views"
	FeaturePartitioning      = "partitioning"
	FeatureIndexing          = "indexing"
	FeatureCaching           = "caching"
)

Common feature flags

View Source
const (
	LimitMaxQuerySize   = "max_query_size"
	LimitMaxResultSize  = "max_result_size"
	LimitMaxConcurrency = "max_concurrency"
	LimitQueryTimeout   = "query_timeout_ms"
	LimitRateLimit      = "rate_limit_per_second"
	LimitMaxConnections = "max_connections"
)

Common limits

View Source
const (
	// DefaultSharedMemoryThreshold is 100KB
	DefaultSharedMemoryThreshold = 100 * 1024
)

Variables

This section is empty.

Functions

func ClassifyError

func ClassifyError(err error) string

ClassifyError attempts to determine error type from error message. This can be used by backends to categorize errors for better corrections.

func InferErrorType

func InferErrorType(errorCode, errorMessage string) string

InferErrorType attempts to classify error from code/message. Backend-specific implementations can override this.

func List

func List() []string

List returns all registered backend names from the global registry.

func LoadBackend

func LoadBackend(path string) (*loomv1.BackendConfig, error)

LoadBackend loads a backend configuration from a YAML file

func Register

func Register(name string, factory BackendFactory)

Register registers a backend factory in the global registry.

func Unregister

func Unregister(name string)

Unregister removes a backend factory from the global registry.

Types

type AuthConfigYAML

type AuthConfigYAML struct {
	Type       string `yaml:"type"`
	Token      string `yaml:"token"`
	Username   string `yaml:"username"`
	Password   string `yaml:"password"`
	HeaderName string `yaml:"header_name"`
}

type BackendFactory

type BackendFactory func(config map[string]interface{}) (ExecutionBackend, error)

BackendFactory is a function that creates a new ExecutionBackend instance.

func Get

func Get(name string) (BackendFactory, bool)

Get retrieves a backend factory from the global registry.

type BackendYAML

type BackendYAML struct {
	APIVersion      string                  `yaml:"apiVersion"`
	Kind            string                  `yaml:"kind"`
	Name            string                  `yaml:"name"`
	Description     string                  `yaml:"description"`
	Type            string                  `yaml:"type"`
	Database        *DatabaseConnectionYAML `yaml:"database"`
	Rest            *RestConnectionYAML     `yaml:"rest"`
	GraphQL         *GraphQLConnectionYAML  `yaml:"graphql"`
	GRPC            *GRPCConnectionYAML     `yaml:"grpc"`
	MCP             *MCPConnectionYAML      `yaml:"mcp"`
	SchemaDiscovery *SchemaDiscoveryYAML    `yaml:"schema_discovery"`
	ToolGeneration  *ToolGenerationYAML     `yaml:"tool_generation"`
	HealthCheck     *HealthCheckYAML        `yaml:"health_check"`
}

BackendYAML represents the YAML structure for backend configuration

type Capabilities

type Capabilities struct {
	// SupportsTransactions indicates if the backend supports transactions
	SupportsTransactions bool

	// SupportsConcurrency indicates if the backend supports concurrent operations
	SupportsConcurrency bool

	// SupportsStreaming indicates if the backend supports streaming results
	SupportsStreaming bool

	// MaxConcurrentOps is the maximum number of concurrent operations
	MaxConcurrentOps int

	// SupportedOperations lists supported custom operations
	SupportedOperations []string

	// Features lists backend-specific features
	Features map[string]bool

	// Limits contains backend-specific limits
	Limits map[string]int64
}

Capabilities describes what a backend supports.

func NewCapabilities

func NewCapabilities() *Capabilities

NewCapabilities creates a new Capabilities instance with default values.

func (*Capabilities) GetLimit

func (c *Capabilities) GetLimit(name string) (int64, bool)

GetLimit retrieves a backend-specific limit.

func (*Capabilities) HasFeature

func (c *Capabilities) HasFeature(name string) bool

HasFeature checks if a feature is enabled.

func (*Capabilities) SupportsOperation

func (c *Capabilities) SupportsOperation(op string) bool

SupportsOperation checks if a custom operation is supported.

func (*Capabilities) WithConcurrency

func (c *Capabilities) WithConcurrency(supported bool, maxOps int) *Capabilities

WithConcurrency sets concurrency support and max operations.

func (*Capabilities) WithFeature

func (c *Capabilities) WithFeature(name string, enabled bool) *Capabilities

WithFeature sets a backend-specific feature flag.

func (*Capabilities) WithLimit

func (c *Capabilities) WithLimit(name string, value int64) *Capabilities

WithLimit sets a backend-specific limit.

func (*Capabilities) WithOperation

func (c *Capabilities) WithOperation(op string) *Capabilities

WithOperation adds a supported custom operation.

func (*Capabilities) WithStreaming

func (c *Capabilities) WithStreaming(supported bool) *Capabilities

WithStreaming sets streaming support.

func (*Capabilities) WithTransactions

func (c *Capabilities) WithTransactions(supported bool) *Capabilities

WithTransactions sets transaction support.

type CircuitBreaker

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

CircuitBreaker implements the circuit breaker pattern to prevent cascading failures. It tracks failures per-tool and uses exponential backoff for automatic recovery.

func NewCircuitBreaker

func NewCircuitBreaker(config CircuitBreakerConfig) *CircuitBreaker

NewCircuitBreaker creates a new circuit breaker.

func (*CircuitBreaker) Execute

func (cb *CircuitBreaker) Execute(operation func() error) error

Execute wraps an operation with circuit breaker logic.

func (*CircuitBreaker) ExecuteEx

func (cb *CircuitBreaker) ExecuteEx(operation func() error, isValidation bool) error

ExecuteEx wraps an operation with circuit breaker logic, with optional validation flag. When isValidation=true, errors are logged but do NOT count toward circuit breaker threshold. This is used for pre-flight validation checks that are expected to catch errors.

func (*CircuitBreaker) GetState

func (cb *CircuitBreaker) GetState() CircuitState

GetState returns the current circuit state (thread-safe).

func (*CircuitBreaker) GetStats

func (cb *CircuitBreaker) GetStats() CircuitBreakerStats

GetStats returns current circuit breaker statistics.

func (*CircuitBreaker) GetTimeout

func (cb *CircuitBreaker) GetTimeout() time.Duration

GetTimeout returns the current exponential backoff timeout.

func (*CircuitBreaker) Reset

func (cb *CircuitBreaker) Reset()

Reset manually resets the circuit breaker to closed state. This allows manual recovery without waiting for the timeout.

type CircuitBreakerConfig

type CircuitBreakerConfig struct {
	FailureThreshold int           // Number of consecutive failures to open circuit (default: 5)
	SuccessThreshold int           // Number of consecutive successes to close from half-open (default: 2)
	Timeout          time.Duration // Time to wait before attempting half-open (default: 30s)
	OnStateChange    func(from, to CircuitState)
}

CircuitBreakerConfig defines circuit breaker behavior.

func DefaultCircuitBreakerConfig

func DefaultCircuitBreakerConfig() CircuitBreakerConfig

DefaultCircuitBreakerConfig returns sensible defaults.

type CircuitBreakerManager

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

CircuitBreakerManager manages per-tool circuit breakers to prevent one failing tool from blocking all other tools. Each tool gets its own circuit breaker with independent state.

func NewCircuitBreakerManager

func NewCircuitBreakerManager(config CircuitBreakerConfig) *CircuitBreakerManager

NewCircuitBreakerManager creates a new manager with the given default config.

func (*CircuitBreakerManager) GetAllStats

func (m *CircuitBreakerManager) GetAllStats() map[string]CircuitBreakerStats

GetAllStats returns statistics for all circuit breakers. Returns a map of tool name -> circuit breaker stats.

func (*CircuitBreakerManager) GetBreaker

func (m *CircuitBreakerManager) GetBreaker(toolName string) *CircuitBreaker

GetBreaker returns the circuit breaker for the given tool name, creating one if needed. This is thread-safe and uses double-checked locking for performance.

func (*CircuitBreakerManager) Reset

func (m *CircuitBreakerManager) Reset(toolName string)

Reset resets the circuit breaker for a specific tool.

func (*CircuitBreakerManager) ResetAll

func (m *CircuitBreakerManager) ResetAll()

ResetAll resets all circuit breakers.

type CircuitBreakerStats

type CircuitBreakerStats struct {
	State            CircuitState
	FailureCount     int
	SuccessCount     int
	LastFailureTime  time.Time
	LastStateChange  time.Time
	FailureThreshold int
	SuccessThreshold int
	ConsecutiveOpens int
}

CircuitBreakerStats contains circuit breaker statistics.

type CircuitState

type CircuitState int

CircuitState represents the current state of the circuit breaker.

const (
	StateClosed   CircuitState = iota // Normal operation
	StateOpen                         // Failing - reject requests immediately
	StateHalfOpen                     // Testing - allow limited requests
)

func (CircuitState) String

func (s CircuitState) String() string

type Column

type Column struct {
	Name     string
	Type     string
	Nullable bool
}

Column represents a column in tabular results.

type Correction

type Correction struct {
	OriginalSQL     string
	CorrectedSQL    string
	Explanation     string
	ErrorCode       string
	ConfidenceLevel string // "high", "medium", "low"
}

Correction represents a suggested fix for an error.

type DatabaseConnectionYAML

type DatabaseConnectionYAML struct {
	DSN                      string `yaml:"dsn"`
	MaxConnections           int    `yaml:"max_connections"`
	MaxIdleConnections       int    `yaml:"max_idle_connections"`
	ConnectionTimeoutSeconds int    `yaml:"connection_timeout_seconds"`
	EnableSSL                bool   `yaml:"enable_ssl"`
	SSLCertPath              string `yaml:"ssl_cert_path"`
}

type ErrorAnalysisInfo

type ErrorAnalysisInfo struct {
	ErrorType   string   // e.g., "syntax_error", "permission_denied", "table_not_found"
	Summary     string   // Human-readable error summary
	Suggestions []string // Actionable suggestions for fixing
}

ErrorAnalysisInfo contains detailed error analysis for self-correction.

type ErrorRecord

type ErrorRecord struct {
	SQL              string
	ErrorCode        string
	ErrorMessage     string
	Timestamp        string
	AttemptCount     int                // Tracks retry attempts
	PreviousAttempts []string           // History of failed SQL
	ErrorAnalysis    *ErrorAnalysisInfo // Enhanced error analysis
}

ErrorRecord stores recent error information for self-correction.

type ExecutionBackend

type ExecutionBackend interface {
	// Name returns the backend identifier (e.g., "teradata", "postgres", "rest-api")
	Name() string

	// ExecuteQuery executes a domain-specific query or operation.
	// For SQL backends: query is SQL, result contains rows/columns
	// For API backends: query is HTTP request spec, result contains response
	// For document backends: query is search criteria, result contains documents
	ExecuteQuery(ctx context.Context, query string) (*QueryResult, error)

	// GetSchema retrieves schema information for a resource.
	// For SQL: table/view schema with columns and types
	// For API: endpoint specifications
	// For documents: index schema
	GetSchema(ctx context.Context, resource string) (*Schema, error)

	// ListResources lists available resources with optional filtering.
	// For SQL: tables, views, procedures
	// For API: available endpoints
	// For documents: available indexes/collections
	ListResources(ctx context.Context, filters map[string]string) ([]Resource, error)

	// GetMetadata retrieves backend-specific metadata for a resource.
	// Examples: table statistics, index info, API rate limits, etc.
	GetMetadata(ctx context.Context, resource string) (map[string]interface{}, error)

	// Ping checks backend connectivity and health.
	Ping(ctx context.Context) error

	// Capabilities returns the backend's capabilities for feature discovery.
	Capabilities() *Capabilities

	// ExecuteCustomOperation allows backend-specific operations not covered by
	// the standard interface. This provides an extension point for specialized
	// functionality while maintaining interface compatibility.
	ExecuteCustomOperation(ctx context.Context, op string, params map[string]interface{}) (interface{}, error)

	// Close releases backend resources.
	Close() error
}

ExecutionBackend defines the interface for pluggable execution backends. Implementations can be SQL databases (Teradata, Postgres, Snowflake), REST APIs, document stores, or any other domain-specific execution engine.

This interface is intentionally minimal to support diverse backends while maintaining a common contract for the agent framework.

func Create

func Create(name string, config map[string]interface{}) (ExecutionBackend, error)

Create creates a new backend instance from the global registry.

type ExecutionStats

type ExecutionStats struct {
	// Duration in milliseconds
	DurationMs int64

	// BytesScanned for data operations
	BytesScanned int64

	// RowsAffected for write operations
	RowsAffected int64

	// Cost estimate (backend-specific units)
	EstimatedCost float64
}

ExecutionStats tracks execution metrics.

type Field

type Field struct {
	Name        string
	Type        string
	Description string
	Nullable    bool
	PrimaryKey  bool
	ForeignKey  *ForeignKey
	Constraints []string
	Default     interface{}
}

Field represents a field/column in a schema.

type ForeignKey

type ForeignKey struct {
	ReferencedTable  string
	ReferencedColumn string
}

ForeignKey represents a foreign key relationship.

type GRPCConnectionYAML

type GRPCConnectionYAML struct {
	Address        string            `yaml:"address"`
	UseTLS         bool              `yaml:"use_tls"`
	CertPath       string            `yaml:"cert_path"`
	Metadata       map[string]string `yaml:"metadata"`
	TimeoutSeconds int               `yaml:"timeout_seconds"`
}

type GraphQLConnectionYAML

type GraphQLConnectionYAML struct {
	Endpoint       string            `yaml:"endpoint"`
	Auth           *AuthConfigYAML   `yaml:"auth"`
	Headers        map[string]string `yaml:"headers"`
	TimeoutSeconds int               `yaml:"timeout_seconds"`
}

type GuardrailEngine

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

GuardrailEngine performs pre-flight validation and error correction. It tracks errors across attempts and provides self-correction suggestions.

func NewGuardrailEngine

func NewGuardrailEngine() *GuardrailEngine

NewGuardrailEngine creates a new guardrail engine.

func (*GuardrailEngine) ClearErrorRecord

func (g *GuardrailEngine) ClearErrorRecord(sessionID string)

ClearErrorRecord removes error history for a session (e.g., on successful execution).

func (*GuardrailEngine) GetErrorRecord

func (g *GuardrailEngine) GetErrorRecord(sessionID string) *ErrorRecord

GetErrorRecord retrieves the error history for a session.

func (*GuardrailEngine) HandleError

func (g *GuardrailEngine) HandleError(ctx context.Context, sessionID, sql, errorCode, errorMessage string) *Correction

HandleError analyzes an error and suggests corrections. This is the basic version without enhanced error analysis.

func (*GuardrailEngine) HandleErrorWithAnalysis

func (g *GuardrailEngine) HandleErrorWithAnalysis(ctx context.Context, sessionID, sql string, analysis *ErrorAnalysisInfo) *Correction

HandleErrorWithAnalysis analyzes an error with enhanced context and suggests corrections. This is the primary entry point for self-correction.

func (*GuardrailEngine) PreflightCheck

func (g *GuardrailEngine) PreflightCheck(ctx context.Context, sql string) []Issue

PreflightCheck performs validation before SQL execution. Returns issues found across all registered validators.

func (*GuardrailEngine) RegisterValidator

func (g *GuardrailEngine) RegisterValidator(v Validator)

RegisterValidator adds a backend-specific validator.

type HealthCheckYAML

type HealthCheckYAML struct {
	Enabled         bool   `yaml:"enabled"`
	IntervalSeconds int    `yaml:"interval_seconds"`
	TimeoutSeconds  int    `yaml:"timeout_seconds"`
	Query           string `yaml:"query"`
}

type InstrumentedBackend

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

InstrumentedBackend wraps any ExecutionBackend with observability instrumentation. It captures detailed traces and metrics for every backend operation, including: - Query execution with timing and result metrics - Schema operations - Resource listing - Metadata retrieval - Health checks

This wrapper is transparent and can wrap any ExecutionBackend implementation.

func NewInstrumentedBackend

func NewInstrumentedBackend(backend ExecutionBackend, tracer observability.Tracer) *InstrumentedBackend

NewInstrumentedBackend creates a new instrumented execution backend.

func (*InstrumentedBackend) Capabilities

func (ib *InstrumentedBackend) Capabilities() *Capabilities

Capabilities returns the underlying backend capabilities.

func (*InstrumentedBackend) Close

func (ib *InstrumentedBackend) Close() error

Close releases resources.

func (*InstrumentedBackend) ExecuteCustomOperation

func (ib *InstrumentedBackend) ExecuteCustomOperation(ctx context.Context, op string, params map[string]interface{}) (interface{}, error)

ExecuteCustomOperation executes custom operations with observability.

func (*InstrumentedBackend) ExecuteQuery

func (ib *InstrumentedBackend) ExecuteQuery(ctx context.Context, query string) (*QueryResult, error)

ExecuteQuery executes a query with observability instrumentation.

func (*InstrumentedBackend) GetMetadata

func (ib *InstrumentedBackend) GetMetadata(ctx context.Context, resource string) (map[string]interface{}, error)

GetMetadata retrieves metadata with observability instrumentation.

func (*InstrumentedBackend) GetSchema

func (ib *InstrumentedBackend) GetSchema(ctx context.Context, resource string) (*Schema, error)

GetSchema retrieves schema with observability instrumentation.

func (*InstrumentedBackend) ListResources

func (ib *InstrumentedBackend) ListResources(ctx context.Context, filters map[string]string) ([]Resource, error)

ListResources lists resources with observability instrumentation.

func (*InstrumentedBackend) Name

func (ib *InstrumentedBackend) Name() string

Name returns the underlying backend name.

func (*InstrumentedBackend) Ping

func (ib *InstrumentedBackend) Ping(ctx context.Context) error

Ping checks connectivity with observability instrumentation.

type Issue

type Issue struct {
	Severity    string // "error", "warning", "info"
	Message     string
	Suggestion  string
	LineNumber  int
	ColumnRange string
}

Issue represents a validation issue found during pre-flight check.

type MCPConnectionYAML

type MCPConnectionYAML struct {
	Command    string            `yaml:"command"`
	Args       []string          `yaml:"args"`
	Env        map[string]string `yaml:"env"`
	Transport  string            `yaml:"transport"`
	URL        string            `yaml:"url"`
	WorkingDir string            `yaml:"working_dir"`
}

type QueryResult

type QueryResult struct {
	// Type indicates the result type (e.g., "rows", "document", "response")
	Type string

	// Data contains the actual result data (format varies by backend)
	// For small results (<100KB), data is stored here directly
	// For large results, use DataReference instead
	Data interface{}

	// Rows for tabular results (SQL)
	Rows []map[string]interface{}

	// Columns for tabular results (SQL)
	Columns []Column

	// RowCount for tabular results
	RowCount int

	// Metadata contains backend-specific result metadata
	Metadata map[string]interface{}

	// ExecutionStats tracks execution metrics
	ExecutionStats ExecutionStats

	// DataReference points to large result data stored in shared memory
	// If set, Data/Rows fields should be empty and actual data retrieved via reference
	DataReference *loomv1.DataReference
}

QueryResult represents the result of executing a query or operation.

type Registry

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

Registry manages backend factories and allows dynamic registration.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new backend registry.

func (*Registry) Create

func (r *Registry) Create(name string, config map[string]interface{}) (ExecutionBackend, error)

Create creates a new backend instance using the registered factory.

func (*Registry) Get

func (r *Registry) Get(name string) (BackendFactory, bool)

Get retrieves a backend factory by name.

func (*Registry) List

func (r *Registry) List() []string

List returns all registered backend names.

func (*Registry) Register

func (r *Registry) Register(name string, factory BackendFactory)

Register registers a backend factory with the given name. If a factory with the same name already exists, it will be replaced.

func (*Registry) Unregister

func (r *Registry) Unregister(name string)

Unregister removes a backend factory from the registry.

type Resource

type Resource struct {
	Name        string
	Type        string
	Description string
	Metadata    map[string]interface{}
}

Resource represents an available resource in the backend.

type RestConnectionYAML

type RestConnectionYAML struct {
	BaseURL        string            `yaml:"base_url"`
	Auth           *AuthConfigYAML   `yaml:"auth"`
	Headers        map[string]string `yaml:"headers"`
	TimeoutSeconds int               `yaml:"timeout_seconds"`
	MaxRetries     int               `yaml:"max_retries"`
}

type Schema

type Schema struct {
	// Resource name (table, endpoint, collection, etc.)
	Name string

	// Type of resource (table, view, api_endpoint, etc.)
	Type string

	// Fields/columns/properties
	Fields []Field

	// Metadata contains additional schema information
	Metadata map[string]interface{}
}

Schema represents the schema of a resource.

type SchemaDiscoveryYAML

type SchemaDiscoveryYAML struct {
	Enabled         bool     `yaml:"enabled"`
	CacheTTLSeconds int      `yaml:"cache_ttl_seconds"`
	IncludeTables   []string `yaml:"include_tables"`
	ExcludeTables   []string `yaml:"exclude_tables"`
}

type SharedBackendConfig

type SharedBackendConfig struct {
	// Backend is the underlying execution backend to wrap
	Backend ExecutionBackend

	// SharedMemory is the shared memory store
	SharedMemory *storage.SharedMemoryStore

	// Threshold is the size threshold for using shared memory (bytes)
	// Results larger than this will be stored in shared memory
	Threshold int64

	// AutoStore automatically stores large results (default: true)
	AutoStore bool

	// Logger for structured logging (default: NoOp logger)
	Logger *zap.Logger
}

SharedBackendConfig configures the shared backend wrapper.

type SharedBackendWrapper

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

SharedBackendWrapper wraps an ExecutionBackend to automatically store large results in shared memory.

func NewSharedBackendWrapper

func NewSharedBackendWrapper(config *SharedBackendConfig) (*SharedBackendWrapper, error)

NewSharedBackendWrapper creates a new shared backend wrapper.

func (*SharedBackendWrapper) Capabilities

func (w *SharedBackendWrapper) Capabilities() *Capabilities

Capabilities delegates to wrapped backend.

func (*SharedBackendWrapper) Close

func (w *SharedBackendWrapper) Close() error

Close closes both the wrapper and wrapped backend.

func (*SharedBackendWrapper) ExecuteCustomOperation

func (w *SharedBackendWrapper) ExecuteCustomOperation(ctx context.Context, op string, params map[string]interface{}) (interface{}, error)

ExecuteCustomOperation delegates to wrapped backend.

func (*SharedBackendWrapper) ExecuteQuery

func (w *SharedBackendWrapper) ExecuteQuery(ctx context.Context, query string) (*QueryResult, error)

ExecuteQuery executes a query and automatically stores large results in shared memory.

func (*SharedBackendWrapper) GetMetadata

func (w *SharedBackendWrapper) GetMetadata(ctx context.Context, resource string) (map[string]interface{}, error)

GetMetadata delegates to wrapped backend.

func (*SharedBackendWrapper) GetSchema

func (w *SharedBackendWrapper) GetSchema(ctx context.Context, resource string) (*Schema, error)

GetSchema delegates to wrapped backend.

func (*SharedBackendWrapper) ListResources

func (w *SharedBackendWrapper) ListResources(ctx context.Context, filters map[string]string) ([]Resource, error)

ListResources delegates to wrapped backend.

func (*SharedBackendWrapper) Name

func (w *SharedBackendWrapper) Name() string

Name returns the wrapped backend's name.

func (*SharedBackendWrapper) Ping

Ping delegates to wrapped backend.

func (*SharedBackendWrapper) RetrieveFromSharedMemory

func (w *SharedBackendWrapper) RetrieveFromSharedMemory(ref *loomv1.DataReference) ([]byte, error)

RetrieveFromSharedMemory retrieves data from shared memory using a reference.

type ToolGenerationYAML

type ToolGenerationYAML struct {
	Tools     []string `yaml:"tools"`
	EnableAll bool     `yaml:"enable_all"`
}

type Validator

type Validator interface {
	Name() string
	Validate(ctx context.Context, sql string) []Issue
}

Validator interface allows backend-specific validation rules.

Directories

Path Synopsis
Package factory provides a factory for creating ExecutionBackend instances from YAML configuration files.
Package factory provides a factory for creating ExecutionBackend instances from YAML configuration files.

Jump to

Keyboard shortcuts

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