pgproxy

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2025 License: MIT Imports: 12 Imported by: 0

README

PG Proxy

sequenceDiagram
    participant App
    participant Proxy
    participant RDS


    Proxy ->> Proxy : Listen
    App ->> Proxy : Dial
    Proxy -->> App : Accept
    App ->> Proxy : PG StartupMessage<br>user = database = MAIN
    Proxy ->> Creds : Get Creds for DB = MAIN
    Creds ->> o5 : $DB_CREDS_MAIN
    o5 -->> Creds : dbName=env_app_main<br>endpoint=...amazonaws.com
    Creds -->> Proxy : Return Creds
    Proxy ->> RDS : Dial
    RDS -->> Proxy : Accept
    loop auth flow using PGX library
        Proxy ->> RDS : PG Authentication
        RDS -->> Proxy : PG Response
    end
    Proxy ->> Proxy : Hijack Conn
    Proxy -->> App : AuthenticationOk
    Proxy -->> App : ReadyForQuery

    note over App,RDS: Proxy streams messages in <br> full duplex until EOF

    par App to RDS
        App ->> Proxy : MSG
        Proxy ->> RDS : MSG
    and RDS to App
        RDS ->> Proxy : MSG
        Proxy ->> App : MSG
    end


Documentation

Index

Constants

View Source
const TxStatusIdle = 'I'

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	// contains filtered or unexported fields
}

func NewApp

func NewApp(cfg ProxyConfig, pgConfigs pgclient.ConfigSet) (*App, error)

func (*App) Run

func (pp *App) Run(ctx context.Context) error

type Frontend

type Frontend struct {
	// contains filtered or unexported fields
}

func (*Frontend) Close

func (f *Frontend) Close()

func (*Frontend) Frontend

func (f *Frontend) Frontend() *pgproto3.Frontend

type Listener

type Listener struct {
	// contains filtered or unexported fields
}

func NewListener

func NewListener(network, bind string, dbs map[string]pgclient.PGConnector) (*Listener, error)

func (*Listener) Listen

func (ll *Listener) Listen(ctx context.Context) error

type ProxyConfig

type ProxyConfig struct {
	PostgresProxy     []string `env:"POSTGRES_IAM_PROXY" default:""`
	PostgresProxyBind string   `env:"POSTGRES_PROXY_BIND" default:"/socket/postgres"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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