pg

package
v1.7.11 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPostgresPort = "5432"

DefaultPostgresPort is the default port for Postgres database connections over TCP

Variables

This section is empty.

Functions

func GetTCPPlugin

func GetTCPPlugin() tcp.Plugin

GetTCPPlugin is required as part of the Secretless plugin spec for TCP connector plugins. It returns the TCP plugin.

func NewConnector

func NewConnector(conRes connector.Resources) tcp.Connector

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

func PluginInfo() map[string]string

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:

  1. Constructs connection details from the provided credentials map.
  2. Dials the backend using credentials.
  3. 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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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