database

package
v0.0.0-...-be19471 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCacheTTL = 5 * time.Minute

DefaultCacheTTL is the default time-to-live for cached metadata

Variables

This section is empty.

Functions

This section is empty.

Types

type AIProvider

type AIProvider struct {
	Type       string
	ProviderId string
}

type ChatMessage

type ChatMessage struct {
	Type   string
	Result *engine.GetRowsResult
	Text   string
}

type Connection

type Connection = config.Connection

type Manager

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

func NewManager

func NewManager() (*Manager, error)

func (*Manager) Connect

func (m *Manager) Connect(conn *Connection) error

func (*Manager) Disconnect

func (m *Manager) Disconnect() error

func (*Manager) ExecuteQuery

func (m *Manager) ExecuteQuery(query string) (*engine.GetRowsResult, error)

func (*Manager) ExecuteQueryWithContext

func (m *Manager) ExecuteQueryWithContext(ctx context.Context, query string) (*engine.GetRowsResult, error)

ExecuteQueryWithContext executes a query with context support for cancellation and timeout. If the context is cancelled or times out, the function returns immediately with ctx.Err(). Note: The underlying database operation may continue running; only the wait is cancelled.

func (*Manager) ExportResultsToCSV

func (m *Manager) ExportResultsToCSV(result *engine.GetRowsResult, filename, delimiter string) error

func (*Manager) ExportResultsToExcel

func (m *Manager) ExportResultsToExcel(result *engine.GetRowsResult, filename string) error

func (*Manager) ExportToCSV

func (m *Manager) ExportToCSV(schema, storageUnit, filename, delimiter string) error

func (*Manager) ExportToExcel

func (m *Manager) ExportToExcel(schema, storageUnit, filename string) error

func (*Manager) GetAIModels

func (m *Manager) GetAIModels(providerID, modelType, token string) ([]string, error)

func (*Manager) GetAIModelsWithContext

func (m *Manager) GetAIModelsWithContext(ctx context.Context, providerID, modelType, token string) ([]string, error)

GetAIModelsWithContext fetches AI models with context support for timeout/cancellation

func (*Manager) GetAIProviders

func (m *Manager) GetAIProviders() []AIProvider

func (*Manager) GetCache

func (m *Manager) GetCache() *MetadataCache

GetCache returns the metadata cache (primarily for testing)

func (*Manager) GetColumns

func (m *Manager) GetColumns(schema, storageUnit string) ([]engine.Column, error)

func (*Manager) GetConfig

func (m *Manager) GetConfig() *config.Config

GetConfig returns the manager's configuration

func (*Manager) GetConnection

func (m *Manager) GetConnection(name string) (*Connection, error)

func (*Manager) GetCurrentConnection

func (m *Manager) GetCurrentConnection() *Connection

func (*Manager) GetRows

func (m *Manager) GetRows(schema, storageUnit string, where *model.WhereCondition, pageSize, pageOffset int) (*engine.GetRowsResult, error)

func (*Manager) GetRowsWithContext

func (m *Manager) GetRowsWithContext(ctx context.Context, schema, storageUnit string, where *model.WhereCondition, pageSize, pageOffset int) (*engine.GetRowsResult, error)

GetRowsWithContext fetches rows with context support for cancellation and timeout. If the context is cancelled or times out, the function returns immediately with ctx.Err(). Note: The underlying database operation may continue running; only the wait is cancelled.

func (*Manager) GetSchemas

func (m *Manager) GetSchemas() ([]string, error)

func (*Manager) GetSchemasWithContext

func (m *Manager) GetSchemasWithContext(ctx context.Context) ([]string, error)

GetSchemasWithContext fetches schemas with context support for cancellation and timeout.

func (*Manager) GetStorageUnits

func (m *Manager) GetStorageUnits(schema string) ([]engine.StorageUnit, error)

func (*Manager) GetStorageUnitsWithContext

func (m *Manager) GetStorageUnitsWithContext(ctx context.Context, schema string) ([]engine.StorageUnit, error)

GetStorageUnitsWithContext fetches storage units with context support for cancellation and timeout.

func (*Manager) InvalidateCache

func (m *Manager) InvalidateCache()

InvalidateCache clears all cached metadata, forcing fresh fetches on next access. Useful when the database schema has changed externally.

func (*Manager) ListConnections

func (m *Manager) ListConnections() []Connection

func (*Manager) SendAIChat

func (m *Manager) SendAIChat(providerID, modelType, token, schema, model, previousConversation, query string) ([]*ChatMessage, error)

func (*Manager) SendAIChatWithContext

func (m *Manager) SendAIChatWithContext(ctx context.Context, providerID, modelType, token, schema, model, previousConversation, query string) ([]*ChatMessage, error)

SendAIChatWithContext sends AI chat with context support for timeout/cancellation

type MetadataCache

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

MetadataCache provides thread-safe caching for database metadata to reduce network calls during autocomplete operations.

func NewMetadataCache

func NewMetadataCache(ttl time.Duration) *MetadataCache

NewMetadataCache creates a new metadata cache with the specified TTL

func (*MetadataCache) Clear

func (c *MetadataCache) Clear()

Clear removes all cached data

func (*MetadataCache) GetColumns

func (c *MetadataCache) GetColumns(schema, table string) ([]engine.Column, bool)

GetColumns returns cached columns for a table if valid, or nil if expired/missing

func (*MetadataCache) GetSchemas

func (c *MetadataCache) GetSchemas() ([]string, bool)

GetSchemas returns cached schemas if valid, or nil if expired/missing

func (*MetadataCache) GetTables

func (c *MetadataCache) GetTables(schema string) ([]engine.StorageUnit, bool)

GetTables returns cached tables for a schema if valid, or nil if expired/missing

func (*MetadataCache) SetColumns

func (c *MetadataCache) SetColumns(schema, table string, columns []engine.Column)

SetColumns caches the columns for a table

func (*MetadataCache) SetSchemas

func (c *MetadataCache) SetSchemas(schemas []string)

SetSchemas caches the schema list

func (*MetadataCache) SetTables

func (c *MetadataCache) SetTables(schema string, tables []engine.StorageUnit)

SetTables caches the tables for a schema

Jump to

Keyboard shortcuts

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