Documentation ¶
Index ¶
Constants ¶
const DefaultPostgresPort = "5432"
DefaultPostgresPort is the default port for Postgres database connections over TCP
Variables ¶
This section is empty.
Functions ¶
func GetTCPPlugin ¶
GetTCPPlugin is required as part of the Secretless plugin spec for TCP connector plugins. It returns the TCP plugin.
func NewConnector ¶
NewConnector returns a tcp.Connector which returns an authenticated connection to a target service for each incoming client connection. It is a required method on the tcp.Plugin interface. The single argument passed in is of type connector.Resources. It contains connector-specific config and a logger.
func PluginInfo ¶
PluginInfo is required as part of the Secretless plugin spec. It provides important metadata about the plugin.
Types ¶
type ConnectionDetails ¶
type ConnectionDetails struct { Host string Port string Username string Password string Options map[string]string SSLOptions map[string]string }
ConnectionDetails stores the connection info to the target database.
func NewConnectionDetails ¶
func NewConnectionDetails(options map[string][]byte) (*ConnectionDetails, error)
NewConnectionDetails constructs a ConnectionDetails object based on the options passed in that are based on resolved configuration fields.
func (*ConnectionDetails) Address ¶
func (cd *ConnectionDetails) Address() string
Address provides an aggregation of Host and Port fields into a format acceptable by consumers of this class (`net.Dial`).
type SingleUseConnector ¶
type SingleUseConnector struct {
// contains filtered or unexported fields
}
SingleUseConnector is used to create an authenticated connection to a PostgreSQL target service using a client connection and connection details.
func (*SingleUseConnector) Connect ¶
func (s *SingleUseConnector) Connect( clientConn net.Conn, credentialValuesByID connector.CredentialValuesByID, ) (net.Conn, error)
Connect implements the tcp.Connector func signature.
It is the main method of the SingleUseConnector. It:
- Constructs connection details from the provided credentials map.
- Dials the backend using credentials.
- Runs through the connection phase steps to authenticate.
Connect requires "host", "port", "username" and "password" credentials.
func (*SingleUseConnector) ConnectToBackend ¶
func (s *SingleUseConnector) ConnectToBackend() error
ConnectToBackend establishes the connection to the target database and sets the backendConnection field.
func (*SingleUseConnector) Startup ¶
func (s *SingleUseConnector) Startup() error
Startup performs the startup handshake with the client and parses the client options to extract the database name.