Documentation
¶
Index ¶
- Constants
- type AIProvider
- type ChatMessage
- type Connection
- type Manager
- func (m *Manager) Connect(conn *Connection) error
- func (m *Manager) Disconnect() error
- func (m *Manager) ExecuteQuery(query string) (*engine.GetRowsResult, error)
- func (m *Manager) ExecuteQueryWithContext(ctx context.Context, query string) (*engine.GetRowsResult, error)
- func (m *Manager) ExportResultsToCSV(result *engine.GetRowsResult, filename, delimiter string) error
- func (m *Manager) ExportResultsToExcel(result *engine.GetRowsResult, filename string) error
- func (m *Manager) ExportToCSV(schema, storageUnit, filename, delimiter string) error
- func (m *Manager) ExportToExcel(schema, storageUnit, filename string) error
- func (m *Manager) GetAIModels(providerID, modelType, token string) ([]string, error)
- func (m *Manager) GetAIModelsWithContext(ctx context.Context, providerID, modelType, token string) ([]string, error)
- func (m *Manager) GetAIProviders() []AIProvider
- func (m *Manager) GetCache() *MetadataCache
- func (m *Manager) GetColumns(schema, storageUnit string) ([]engine.Column, error)
- func (m *Manager) GetConfig() *config.Config
- func (m *Manager) GetConnection(name string) (*Connection, error)
- func (m *Manager) GetCurrentConnection() *Connection
- func (m *Manager) GetRows(schema, storageUnit string, where *model.WhereCondition, ...) (*engine.GetRowsResult, error)
- func (m *Manager) GetRowsWithContext(ctx context.Context, schema, storageUnit string, where *model.WhereCondition, ...) (*engine.GetRowsResult, error)
- func (m *Manager) GetSchemas() ([]string, error)
- func (m *Manager) GetSchemasWithContext(ctx context.Context) ([]string, error)
- func (m *Manager) GetStorageUnits(schema string) ([]engine.StorageUnit, error)
- func (m *Manager) GetStorageUnitsWithContext(ctx context.Context, schema string) ([]engine.StorageUnit, error)
- func (m *Manager) InvalidateCache()
- func (m *Manager) ListConnections() []Connection
- func (m *Manager) SendAIChat(...) ([]*ChatMessage, error)
- func (m *Manager) SendAIChatWithContext(ctx context.Context, ...) ([]*ChatMessage, error)
- type MetadataCache
- func (c *MetadataCache) Clear()
- func (c *MetadataCache) GetColumns(schema, table string) ([]engine.Column, bool)
- func (c *MetadataCache) GetSchemas() ([]string, bool)
- func (c *MetadataCache) GetTables(schema string) ([]engine.StorageUnit, bool)
- func (c *MetadataCache) SetColumns(schema, table string, columns []engine.Column)
- func (c *MetadataCache) SetSchemas(schemas []string)
- func (c *MetadataCache) SetTables(schema string, tables []engine.StorageUnit)
Constants ¶
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 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 (*Manager) Connect ¶
func (m *Manager) Connect(conn *Connection) error
func (*Manager) Disconnect ¶
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 (*Manager) ExportToExcel ¶
func (*Manager) GetAIModels ¶
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 (*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 (*Manager) GetSchemasWithContext ¶
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) 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