datasource

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package datasource reads a repo's data_sources.yml. The host owns this (it holds connection config / credentials and runs queries); only the name->dbtype mapping is ever passed to the sidecar for SQL-dialect selection, so secrets never cross the IPC boundary.

Index

Constants

View Source
const FileName = "data_sources.yml"

FileName is the data source manifest, inside the repo's config dir (repo.Repo.ConfigDir()).

Variables

View Source
var ErrUnknown = errors.New("no such data source")

ErrUnknown is Connection's answer for a name the repo has no data source by.

Functions

This section is empty.

Types

type DataSource

type DataSource struct {
	Name       string         `json:"name"`
	DBType     string         `json:"dbtype"`
	Connection map[string]any `json:"-"`
	Settings   map[string]any `json:"-"`
}

DataSource describes one data source. Name/DBType are what the sidecar needs to compile SQL (dialect). Connection holds the host-side connection config (passed to canal-query as dbconfig) and is never serialized to the sidecar. Settings are how canal-query connects and queries (timeouts, SSL, the type's own options), passed to it as dbsetting; none leaves each at canal's default.

type DataSources added in v0.9.0

type DataSources interface {
	// Dialects is the data sources the caller may compile against, by name and
	// type.
	Dialects(ctx context.Context) ([]Dialect, error)
	// Connection is the data source by name, connection included. A name the repo
	// has no data source by is ErrUnknown; any other error is the host's, and
	// reaches the caller as it is.
	Connection(ctx context.Context, name string) (DataSource, error)
}

DataSources is how the engine reaches a repo's data sources, asking for no more than a command needs: every data source's dialect, to compile (the engine cannot know which one a dataset uses until it is compiled); one connection, to run a query on the data source it targets. validate asks for neither.

A host serving a managed repo implements it over its own store: Dialects is metadata, and Connection is where one data source's connection is retrieved, and the caller's use of it authorized. A local repo's is its data_sources.yml (Load).

type Dialect added in v0.9.0

type Dialect struct {
	Name   string
	DBType string
}

Dialect is a data source as compiling needs it: its name and its type (the SQL dialect). No connection.

type Set added in v0.9.0

type Set map[string]DataSource

Set is data sources held in memory, by name: what data_sources.yml loads into, or what a host that already holds them all passes. It is a DataSources.

func Load

func Load(configDir string) (Set, error)

Load reads <configDir>/data_sources.yml into a Set.

func (Set) Connection added in v0.9.0

func (s Set) Connection(_ context.Context, name string) (DataSource, error)

Connection is the data source named name in s.

func (Set) Dialects added in v0.9.0

func (s Set) Dialects(context.Context) ([]Dialect, error)

Dialects is every data source in s, sorted by name.

Jump to

Keyboard shortcuts

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