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 ¶
const FileName = "data_sources.yml"
FileName is the data source manifest, inside the repo's config dir (repo.Repo.ConfigDir()).
Variables ¶
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:"-"`
}
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.
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
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 (Set) Connection ¶ added in v0.9.0
Connection is the data source named name in s.