database

package
v0.19.4 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package database provides the domain service for external database introspection (schema, queries, activity). The repository interfaces define what the service needs from a query executor and query memory store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type QueryExecutor

type QueryExecutor interface {
	ExecuteReadQuery(ctx context.Context, query string) (*QueryResult, error)
}

QueryExecutor runs read-only SQL against an external data source. Implemented by connector.QueryExecutor in production.

type QueryResult

type QueryResult struct {
	Columns  []string
	Rows     [][]any
	RowCount int
}

QueryResult holds structured results from a read-only SQL query.

type SchemaResult

type SchemaResult struct {
	Columns  []string `json:"columns"`
	Rows     [][]any  `json:"rows"`
	RowCount int      `json:"row_count"`
}

SchemaResult holds the output of a schema introspection query.

type Service

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

Service provides external database introspection (schema, queries, activity).

func NewService

func NewService(exec QueryExecutor) *Service

NewService creates a database service.

func (*Service) Activity

func (s *Service) Activity(ctx context.Context, query string) (*SchemaResult, error)

Activity returns current database activity (connections, locks, etc.).

func (*Service) Explain

func (s *Service) Explain(ctx context.Context, query string) (*SchemaResult, error)

Explain runs an EXPLAIN on the given query and returns the plan.

func (*Service) Schema

func (s *Service) Schema(ctx context.Context, query string) (*SchemaResult, error)

Schema lists tables/columns from the connected data source.

func (*Service) Tables

func (s *Service) Tables(ctx context.Context, query string) (*SchemaResult, error)

Tables lists all tables by running the provided discovery query.

Jump to

Keyboard shortcuts

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