Documentation
¶
Overview ¶
Package connresolve turns caller connection input into a ready-to-open configuration. input: dialect plus MySQL/TiDB database, connection schema, and request default catalog hints output: one catalog and one qualifier, or ErrCatalogConflict pos: shared MySQL/TiDB catalog-alias rule for metadata-aware Audit and Online Query Access note: if this file changes, update this header and module README.md.
Package connresolve turns caller connection input into a ready-to-open configuration. input: connection, TLS, timeout, and authentication errors from later openers output: a Connection Failure Class with no host, DSN, driver text, or credential pos: shared classification for Transport Connection Resolution; surfaces map class to their own words note: if this file changes, update this header and module README.md.
Package connresolve turns caller connection input into a ready-to-open configuration. input: dialect, catalog hints, omitted-port flags, and raw connection/TLS/authentication errors output: MySQL/TiDB catalog binding, PostgreSQL omitted-port default, and Connection Failure Class pos: application Transport Connection Resolution path that stops before open note: if this file changes, update this header and module README.md.
Package connresolve turns caller connection input into a ready-to-open configuration. input: requested dialect, configured port, and whether the caller set the port explicitly output: 5432 when PostgreSQL is explicit and the port was omitted pos: shared PostgreSQL omitted-port default before open note: if this file changes, update this header and module README.md.
Package connresolve turns caller connection input into a ready-to-open configuration. input: host, socket, user, password sources, TLS files, timeout, dialect, and catalog hints output: a Config ready for auditmeta.Prepare or online.OpenSession, or an Error with FailureClass pos: Transport Connection Resolution entry that stops before open note: if this file changes, update this header and module README.md.
Index ¶
Constants ¶
const ( CodeSocketTCPConflict = "socket_tcp_conflict" CodeTLSMode = "tls_mode" CodeTLSCARequiresEnabled = "tls_ca_requires_enabled" CodeTLSRequiresHost = "tls_requires_host" CodeTLSRequiresUser = "tls_requires_user" CodeTLSNoSocket = "tls_no_socket" CodeTLSCAPath = "tls_ca_path" CodeTLSCARead = "tls_ca_read" CodeTLSCAPEM = "tls_ca_pem" CodeTimeout = "timeout" CodePasswordSource = "password_source" CodePasswordLookup = "password_lookup" CodeCatalogConflict = "catalog_conflict" )
Variables ¶
var ErrCatalogConflict = errors.New("MySQL/TiDB database, schema, and default schema must match when set; use one catalog value")
ErrCatalogConflict indicates MySQL/TiDB catalog hints disagree.
Functions ¶
func ApplyPostgreSQLDefaultPort ¶
ApplyPostgreSQLDefaultPort returns 5432 when dialect is postgresql and the caller did not set a port. Other dialects keep the configured port.
func BindMySQLTiDBCatalog ¶
func BindMySQLTiDBCatalog(dialect, database, connectionSchema, requestedSchema string) (string, string, error)
BindMySQLTiDBCatalog canonicalizes MySQL/TiDB database, connection schema, and request default hints into one catalog and one qualifier. Non-MySQL/TiDB dialects return the database and requested schema unchanged.
Types ¶
type Config ¶
type Config struct {
Host string
Port int
User string
Socket string
Database string
Schema string
Qualifier string
Dialect string
Password string
ConnectTimeout time.Duration
TLSMode string
CACert *x509.CertPool
}
Config is ready-to-open connection configuration. It does not hold a live handle.
type Error ¶
type Error struct {
Class FailureClass
Code string
// contains filtered or unexported fields
}
Error is a Transport Connection Resolution failure with a Connection Failure Class.
type FailureClass ¶
type FailureClass string
FailureClass is a Connection Failure Class. It is not a user-facing sentence.
const ( ClassNone FailureClass = "" ClassValidation FailureClass = "validation" ClassAuthentication FailureClass = "authentication" ClassRefused FailureClass = "refused" ClassTimeout FailureClass = "timeout" ClassTLSHostname FailureClass = "tls_hostname" ClassTLSUnknownCA FailureClass = "tls_unknown_ca" ClassTLSNotOffered FailureClass = "tls_not_offered" ClassTLSCertificate FailureClass = "tls_certificate" ClassTLSHandshake FailureClass = "tls_handshake" ClassConnectionFailed FailureClass = "connection_failed" )
func Classify ¶
func Classify(err error) FailureClass
Classify maps an opener or network error to a Connection Failure Class.
type Request ¶
type Request struct {
Host string
Port int
PortExplicit bool
User string
Socket string
Database string
Schema string
RequestedSchema string
Dialect string
DialectExplicit bool
Password string
PasswordEnv string
PasswordFile string
ConnectTimeout string
TLSMode string
TLSCAFile string
}
Request is caller connection input before open.