postgresql-to-amqp

Crates.iopostgresql-to-amqp
lib.rspostgresql-to-amqp
version0.1.4-pre
sourcesrc
created_at2017-04-04 22:33:46.189569
updated_at2017-07-23 22:05:13.941095
descriptionPostgreSQL to AMQP, forward PostgreSQL notifications to an AMQP queue.
homepagehttps://github.com/FGRibreau/postgresql-to-amqp
repositoryhttps://github.com/FGRibreau/postgresql-to-amqp
max_upload_size
id9643
size7,013
Francois-Guillaume Ribreau (FGRibreau)

documentation

https://docs.rs/postgresql-to-amqp

README

🚇 PostgreSQL to AMQP gateway

Forward PostgreSQL pg_notify notifications to an AMQP queue.

Cargo version Crates.io Crates.io Docker Automated build Docker Pulls Docker Stars

⛴ Cargo

cargo install postgresql-to-amqp

🐳 Docker

docker run --rm -it \
-e POSTGRESQL_URI=postgresql://username:password@domain.tld:port/database \
-e POSTGRESQL_CHANNEL=foo \
-e AMQP_URI=amqp://127.0.0.1:5672/ \
-e AMQP_QUEUE_NAME=queueName fgribreau/postgresql-to-amqp

⚙ Configuration

Configuration is done through environment variables:

  • POSTGRESQL_URI: e.g. postgresql://username:password@domain.tld:port/database
  • POSTGRESQL_CHANNEL: e.g. foo
  • AMQP_URI: e.g. amqp://127.0.0.1:5672/
  • AMQP_QUEUE_NAME: e.g. queueName

🎩 Usage

Start the forwarder:

POSTGRESQL_URI="postgresql://username:password@domain.tld:port/database" POSTGRESQL_CHANNEL="foo" AMQP_URI="amqp://127.0.0.1:5672/" AMQP_QUEUE_NAME="queueName" postgresql-to-amqp

Execute in psql:

SELECT pg_notify('foo', 'payload');

The forwarder will log and forward the notification to the amqp queue:

Forwarding Notification { process_id: 31694, channel: "foo", payload: "payload" } to queue "queueName"

👁 Philosophy

  • Low memory consumption (1,9Mo)

  • Single binary

  • No dependency

  • Predictable performance

🔫 Todo

I will happily accept PRs for this:

  • AMQP connection string (AMQP authentication support) 👻
  • Support JSON message
  • Publish to exchange
  • Add original channel as message property
  • Add postgresql-to-amqp version as message property
  • Let environment variables specify additional message properties
  • Handle AMQP disconnection/reconnection
  • Handle PostgreSQL disconnection/reconnection
  • Health check route
  • Metric route
  • Docker support
  • Kubernetes support 😍
  • Make a first major release with tests ☝️

Related work

  • pgsql-listen-exchange - RabbitMQ Exchange that publishes messages received from PostgreSQL Notifications
Commit count: 32

cargo fmt