pgbroker

module
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: MIT

README

pgbroker

pgbroker is a golang library for building PostgreSQL proxy, which makes it easy to support from simple query logging to complex dynamic database mappings from an external resource controller and modification on data transferred between client and pg in streaming or per message manner.

Usage

static proxy

One example usage of pgbroker is just simple mapping multiple pg instances into one entry for centralizing management.

Please checkout the https://github.com/pioneerworks/pgbroker-static project.

It is a production ready postgres proxy configured by a yaml file, and it is also has a pre-build docker image.

docker pull pioneerworks/pgbroker-static:latest
dynamic proxy

By implementing the PGResolver interface, the proxy is able to acquire different connections based on the client's StartupMessage.

type PGResolver interface {
	GetPGConn(ctx context.Context, clientAddr net.Addr, parameters map[string]string) (net.Conn, error)
}

Please check out the https://github.com/pioneerworks/godemand-example project, which uses godemand as an external http resource controller for dynamic pg mapping.

In this way, the external resource controller is able to do any change to the postgres before connection estiblished, including creating new postgres instance on the fly.

data modification

pgbroker provides MessageHandler and StreamCallback for each postgres protocol v3 messages. Developers can use them to easily modify the data transferred between client and pg in streaming or per message manner.

It is useful when implementing such as data obfuscation and permission control.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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