sources

package
v0.3.13 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 15 Imported by: 3

Documentation

Index

Constants

View Source
const (
	Postgres  types.DataSourceType = "postgres"
	DuckDB    types.DataSourceType = "duckdb"
	MySQL     types.DataSourceType = "mysql"
	MSSQL     types.DataSourceType = "mssql"
	Http      types.DataSourceType = "http"
	Runtime   types.DataSourceType = "runtime"
	Extension types.DataSourceType = "extension"
	Embedding types.DataSourceType = "embedding"

	Airport  types.DataSourceType = "airport"
	DuckLake types.DataSourceType = "ducklake"
	Iceberg  types.DataSourceType = "iceberg"
	HugrApp  types.DataSourceType = "hugr-app"
)

Variables

View Source
var (
	ErrDataSourceNotFound                  = errors.New("data source not found")
	ErrDataSourceExists                    = errors.New("data source already exists")
	ErrDataSourceAttached                  = errors.New("data source is attached")
	ErrDataSourceNotAttached               = errors.New("data source is not attached")
	ErrUnknownDataSourceType               = errors.New("unknown data source type")
	ErrDataSourceAttachedWithDifferentType = errors.New("data source already attached with different type exists")
	ErrEmptyQuery                          = errors.New("empty query")
	ErrQueryParsingFailed                  = errors.New("query parsing failed")
	ErrInvalidDataSourcePath               = errors.New("invalid data source path")
)

Functions

func ApplyEnvVars added in v0.1.9

func ApplyEnvVars(dsn string) (string, error)

func CheckDBExists

func CheckDBExists(ctx context.Context, db *db.Pool, name string, dsType types.DataSourceType) error

func EnsurePgDatabase added in v0.3.3

func EnsurePgDatabase(ctx context.Context, host, port, user, password, dbName string) error

EnsurePgDatabase connects to the PostgreSQL "postgres" maintenance database and creates the target database if it doesn't exist. This is idempotent — it does nothing if the database already exists.

NOTE: The connection to the maintenance database uses sslmode=disable because it targets the same PostgreSQL instance as the main DuckLake connection. In production, the DuckLake PostgreSQL backend should be co-located (same network) with the Hugr query engine, so TLS is not required for the maintenance connection. If your PostgreSQL instance requires TLS, do not use ensure_db — create the database manually instead.

func EscapeSQLString added in v0.3.3

func EscapeSQLString(s string) string

EscapeSQLString escapes single quotes in SQL string literals by doubling them.

Types

type EmbeddingSource added in v0.1.28

type EmbeddingSource interface {
	CreateEmbedding(ctx context.Context, input string) (ctypes.Vector, error)
	CreateEmbeddings(ctx context.Context, input []string) ([]ctypes.Vector, error)
}

type ExtensionSource added in v0.1.12

type ExtensionSource interface {
	IsExtension() bool
}

The data source is a catalog extension.

type HeartbeatConfig added in v0.3.11

type HeartbeatConfig struct {
	Interval   time.Duration
	Timeout    time.Duration
	MaxRetries int
}

HeartbeatConfig holds heartbeat monitoring settings.

type Heartbeater added in v0.3.11

type Heartbeater interface {
	StartHeartbeat(
		config HeartbeatConfig,
		onSuspend func(ctx context.Context, name string) error,
		onRecover func(ctx context.Context, name string) error,
	)
	StopHeartbeat()
}

Heartbeater is implemented by sources that need periodic health monitoring. The service calls StartHeartbeat after successful Attach and StopHeartbeat before Detach.

type ParsedDSN

type ParsedDSN struct {
	Proto    string
	Host     string
	Port     string
	User     string
	Password string
	DBName   string

	Params map[string]string
}

func ParseDSN

func ParseDSN(dsn string) (ParsedDSN, error)

func (ParsedDSN) String added in v0.1.9

func (p ParsedDSN) String() string

type Provisioner added in v0.3.11

type Provisioner interface {
	Provision(ctx context.Context, querier types.Querier) error
}

Provisioner is implemented by sources that need to provision external resources (databases, schemas) after attachment. Called by the data source service after Attach() succeeds. Querier provides access to hugr's GraphQL API for registering/loading data sources and querying system configuration.

type Querier added in v0.3.11

type Querier = types.Querier

Querier provides GraphQL query access for provisioning operations.

type RuntimeSource

type RuntimeSource interface {
	Name() string
	Engine() engines.Engine
	IsReadonly() bool
	AsModule() bool
	Attach(ctx context.Context, db *db.Pool) error
	Catalog(ctx context.Context) (cs.Catalog, error)
}

RuntimeSource is a data source that is attached on start and provides a catalog source.

type RuntimeSourceQuerier

type RuntimeSourceQuerier interface {
	QueryEngineSetup(querier types.Querier)
}

type SelfDescriber

type SelfDescriber interface {
	CatalogSource(ctx context.Context, db *db.Pool) (cs.Catalog, error)
}

type Source

type Source interface {
	Name() string
	Definition() types.DataSource
	Engine() engines.Engine
	IsAttached() bool
	ReadOnly() bool
	Attach(ctx context.Context, db *db.Pool) error
	Detach(ctx context.Context, db *db.Pool) error
}

Jump to

Keyboard shortcuts

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