Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zikani03/postnat
Your App -> Postgres NOTIFY -> NATS
https://github.com/zikani03/postnat
golang listen-notify nats postgresql
Last synced: 6 days ago
JSON representation
Your App -> Postgres NOTIFY -> NATS
- Host: GitHub
- URL: https://github.com/zikani03/postnat
- Owner: zikani03
- License: mit
- Created: 2022-05-09T20:14:00.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-05-09T20:39:39.000Z (over 2 years ago)
- Last Synced: 2024-06-21T18:47:53.775Z (7 months ago)
- Topics: golang, listen-notify, nats, postgresql
- Language: Go
- Homepage:
- Size: 13.7 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
postnat
=======Publish messages to NATS via Postgres' LISTEN/NOTIFY feature.
## Why would I use this?
Let's assume you already have a postgresql backed application and you want to
introduce a Messaging layer but don't have the resources to modify the system
to introduce more dependencies or you just want to put it off for a bit more.`postnat` helps you use the facilities of Postgres to publish messages to a NATS
server with minimal changes to your code.```sql
NOTIFY 'time_us_east', '';
```What `postnat` does is basically listen to all registered patterns and publishes
the payloads to the configured NATS server.## Usage
You can run it like so:
```sh
$ postnat --config "postnat.toml" run
```### CLI
```text
Usage: postnatPublish messages to NATS from PostgreSQL LISTEN/NOTIFY messages
Flags:
-h, --help Show context-sensitive help.
--config="postnat.toml" Location of configuration file
--debug Enable debug mode
--version Show version and quitCommands:
run Start the postnat daemonRun "postnat --help" for more information on a command.
```### Configuration
```toml
[postgres]
host = "localhost"
port = 5432
database = "database"
username = "username"
password = "password"
sslmode = "disable"[nats]
url = "nats://username:password@localhost:4222"
max_reconnects = 10[topics]
listen_for = ["users", "users_id"]
# optional topic prefix
prefix = "app."
# This replaces the underscore when publishing to nats, e.g. emails_signup -> emails.signup
replace_underscore_with_dot = true
```## Building
First clone this repo:
```sh
$ git clone https://github.com/zikani03/postnat
$ cd postnat
```### Building from source
```sh
$ go build ./cmd/postnat.go
```### Docker, with docker compose
Create a configuration file named `development.toml` and update as appropriate, then run:
```sh
$ docker compose up
```---
MIT LICENSE © Zikani Nyirenda Mwase