Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadyForQueryMesage ¶ added in v0.3.0
func ReadyForQueryMesage() []byte
Types ¶
type PgProxyServer ¶
type PgProxyServer struct {
// contains filtered or unexported fields
}
A PgProxyServer is a postgresql server proxy it has a pool of connection to a true postgresql server
func CreatePgProxy ¶
func CreatePgProxy(pgUri string, session PgProxySession) *PgProxyServer
CreatePgProxy create a new proxy for a postgresql server Allows to redirect queries to a true postgresql server pgUri describe the postgresql URI for the postgresql server. See https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
func (*PgProxyServer) Listen ¶
func (p *PgProxyServer) Listen(addr string) error
Listen TCP packets that use Message Flow postgresql protocol create also a connection pool to a postgresql server
type PgProxySession ¶
type PgProxySession interface { // OnConnect handle the postgresql client socket on established connection OnConnect(ctx context.Context, socket *pgx.Conn) error // OnQuery handle the query before the postgresql server // you can edit the query here or simply return an error if // you don't want to send the query to the postgresql server. OnQuery(query *pgproto3.Query) (*pgproto3.Query, error) // OnResult handle the query's result, err is define if something // wrong occured from the postgresql server. OnResult(rows pgx.Rows, err error) // OnClose handle the postgresql client socket before to close the connection OnClose(socket *pgx.Conn) bool }
Define the behavior you want during the session by implementing the PgProxySession interface
type PgServer ¶ added in v0.3.0
type PgServer struct {
// contains filtered or unexported fields
}
A PgServer is a postgresql server proxy
func CreatePgServer ¶ added in v0.3.0
func CreatePgServer(session PgServerSession) *PgServer
CreatePgServer create a new proxy for a postgresql server without a pgxpool.Pool pgUri describe the postgresql URI for the postgresql server. See https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
type PgServerSession ¶ added in v0.3.0
type PgServerSession interface { // OnQuery handle the query before the postgresql server // you can edit the query here or simply return an error if // you don't want to send the query to the postgresql server. OnQuery(query *pgproto3.Query) ([]byte, error) }
PgServerSession define the behavior you want during the session by implementing the PgServerSession interface
type StopGracefully ¶ added in v0.3.0
type StopGracefully struct{}
func (StopGracefully) Signal ¶ added in v0.3.0
func (s StopGracefully) Signal() int