Documentation
¶
Overview ¶
Package connections is the warehouses Brevis may reach, declared once.
THE ECOSYSTEM'S REGISTRY AND NOT THIS SERVICE'S. A client who taught the SDK to load into a warehouse has already said where that warehouse is; a second file saying it again for `/data` would be a second thing to keep right, and the one that drifts is the one nobody reads until a preview is empty. So the file is `brevis.yaml` at the project's root, `serve` reads it today, and the SDK and the gateway read it afterwards.
WHAT IT HOLDS AND WHAT IT NEVER HOLDS: a name, a dialect, and where to FIND a credential -- never the credential. `dsn_from` takes the NAME of an environment variable, which is the rule `--dsn-from` already follows and the gateway's own `dsn_from` before it. The file is in git; a password must not be.
Index ¶
- type Connection
- type Registry
- func (r *Registry) Identity(name string) (string, bool)
- func (r *Registry) Match(d, first string) (Connection, bool)
- func (r *Registry) Named(name string) (dialect.Dialect, func(context.Context) (dialect.Conn, error), bool)
- func (r *Registry) Names() []string
- func (r *Registry) Open(ctx context.Context, d, first string) (dialect.Conn, error)
- func (r *Registry) TargetOf(name, ref string) (string, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
Name string `yaml:"name"`
Dialect string `yaml:"dialect"`
// Project is a BigQuery project id, which IS the connection there: ADC
// does the rest and there is no DSN to hold.
Project string `yaml:"project"`
// DSNFrom is the NAME of the environment variable holding a connection
// string. Never the string.
DSNFrom string `yaml:"dsn_from"`
// contains filtered or unexported fields
}
Connection is one declared warehouse.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is every connection, in the order they were declared.
func Load ¶
Load reads the registry, or refuses it by name.
REFUSED AT BOOT AND NOT AT THE FIRST REQUEST. A service that accepted a broken declaration would answer a readiness probe and then fail the first person who opened a tab, which is a lie told to an orchestrator.
A FILE THAT IS NOT THERE IS NOT A FAILURE: `serve` with no registry is BigQuery-only, which is what V1 and V2 shipped, and refusing to start without a file nobody has written yet would be a service nobody can run.
func (*Registry) Identity ¶ added in v0.5.0
Identity is where a declared connection reaches -- host, port and database, or the project -- and never its credential. Two connections named alike in two deployments are told apart by it: a cache keyed on the name alone would serve one's rows as the other's.
func (*Registry) Match ¶
func (r *Registry) Match(d, first string) (Connection, bool)
Match finds the connection a target names, and NOT FINDING ONE IS AN ANSWER. The screen has to say which connection is missing, and an error carries nothing to put on it.
func (*Registry) Named ¶ added in v0.5.0
func (r *Registry) Named(name string) (dialect.Dialect, func(context.Context) (dialect.Conn, error), bool)
Named finds a connection by the name it was declared with, and how to open it. An endpoint file says `connection: warehouse`; a target is matched by what it points at, and a file somebody wrote names the declaration.
THE OPENER AND NOT A CONNECTION: the caller opens when it has a request, and closes when the request is answered.
func (*Registry) TargetOf ¶ added in v0.5.0
TargetOf is the catalog target of a relation on a declared connection, from the declaration alone -- the form each dialect's own Target writes, so a manifest names the same relation /data does without connecting. The database or project and nothing else: no host, no user, no password.