query

package
v0.32.5 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectionType added in v0.32.2

func ConnectionType(connection string, backends ...Backend) (string, error)

ConnectionType looks up the configured database type using the existing config loader.

func NewConnectionTypeResolver added in v0.32.2

func NewConnectionTypeResolver(backends ...Backend) func(string) (string, error)

NewConnectionTypeResolver shares one lazy config read within a resolution batch. Create a new resolver for each batch so subsequent requests see config edits.

Types

type Backend

type Backend interface {
	Execute(ctx context.Context, connection string, query string) (*QueryResult, error)
}

Backend defines the interface for executing queries against a data source.

type BruinCLIBackend

type BruinCLIBackend struct {
	BruinPath   string         // Path to bruin binary (default: "bruin" from PATH)
	ConfigFile  string         // Path to .bruin.yml
	Config      *config.Config // Preloaded for one CLI operation; servers leave this nil.
	Environment string         // Target environment
}

BruinCLIBackend implements Backend by shelling out to `bruin query`.

func (*BruinCLIBackend) DryRun added in v0.2.0

func (b *BruinCLIBackend) DryRun(ctx context.Context, connection string, sql string) (*DryRunResult, error)

func (*BruinCLIBackend) Execute

func (b *BruinCLIBackend) Execute(ctx context.Context, connection string, sql string) (*QueryResult, error)

type CachedBackend

type CachedBackend struct {
	Backend Backend
	TTL     time.Duration
	// contains filtered or unexported fields
}

CachedBackend wraps a Backend with TTL-based caching.

func NewCachedBackend

func NewCachedBackend(backend Backend, ttl time.Duration) *CachedBackend

func (*CachedBackend) Execute

func (c *CachedBackend) Execute(ctx context.Context, connection string, query string) (*QueryResult, error)

func (*CachedBackend) Invalidate

func (c *CachedBackend) Invalidate()

Invalidate clears all cached entries.

type ColumnInfo

type ColumnInfo struct {
	Name string `json:"name"`
	Type string `json:"type,omitempty"`
}

type DryRunResult added in v0.2.0

type DryRunResult struct {
	Query          string          `json:"query,omitempty"`
	ConnectionName string          `json:"connectionName,omitempty"`
	ConnectionType string          `json:"connectionType,omitempty"`
	Valid          bool            `json:"valid"`
	Columns        []ColumnInfo    `json:"columns,omitempty"`
	Rows           [][]interface{} `json:"rows,omitempty"`
}

DryRunResult captures metadata returned by a query validation run.

type DryRunner added in v0.2.0

type DryRunner interface {
	DryRun(ctx context.Context, connection string, query string) (*DryRunResult, error)
}

DryRunner is implemented by backends that can validate a query without returning result rows.

type QueryResult

type QueryResult struct {
	Columns []ColumnInfo    `json:"columns"`
	Rows    [][]interface{} `json:"rows"`
}

QueryResult represents the tabular result of executing a query.

Jump to

Keyboard shortcuts

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