Help us shape the future of Go! Take the 2026 Go Developer Survey

connections

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 11 Imported by: 0

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

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

func Load(path string) (*Registry, error)

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

func (r *Registry) Identity(name string) (string, bool)

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) Names

func (r *Registry) Names() []string

Names lists the declared connections, for a refusal to name what there is.

func (*Registry) Open

func (r *Registry) Open(ctx context.Context, d, first string) (dialect.Conn, error)

Open connects to the warehouse a target names.

func (*Registry) TargetOf added in v0.5.0

func (r *Registry) TargetOf(name, ref string) (string, bool)

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.

Jump to

Keyboard shortcuts

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