All Projects → ihippik → wal-listener

ihippik / wal-listener

Licence: Apache-2.0 license
PostgreSQL WAL listener

Programming Languages

go
31211 projects - #10 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to wal-listener

go-zero
A cloud-native Go microservices framework with cli tool for productivity.
Stars: ✭ 23,294 (+26073.03%)
Mutual labels:  microservices-architecture
microservice nodejs template
🦄 Microservice Starter Kit by Nodejs + Typescript + Docker + Lerna + Eslint + Prettier
Stars: ✭ 49 (-44.94%)
Mutual labels:  microservices-architecture
mimeo
Extension for specialized, per-table replication between PostgreSQL instances
Stars: ✭ 74 (-16.85%)
Mutual labels:  logical-replication
football-events
Event-Driven microservices with Kafka Streams
Stars: ✭ 57 (-35.96%)
Mutual labels:  microservices-architecture
pg-logical-replication
PostgreSQL Logical Replication client for node.js
Stars: ✭ 56 (-37.08%)
Mutual labels:  logical-replication
netifi-quickstart-java
Project to assist you in getting started using Netifi.
Stars: ✭ 23 (-74.16%)
Mutual labels:  microservices-architecture
auction-website
🔨 A full-stack real-time auction website built using a microservices architecture
Stars: ✭ 71 (-20.22%)
Mutual labels:  microservices-architecture
muon-java
Muon Core for the JVM. APIs and Microservices taken to the next level
Stars: ✭ 18 (-79.78%)
Mutual labels:  microservices-architecture
springboard-cloud
基于Spring cloud、dubbo、oauth2的微服务应用
Stars: ✭ 16 (-82.02%)
Mutual labels:  microservices-architecture
micro-livraria
Exemplo prático de uma pequena livraria virtual implementada usando microsserviços. Inclui também duas tarefas práticas para os alunos.
Stars: ✭ 91 (+2.25%)
Mutual labels:  microservices-architecture
if1007
Desenvolvimento de Aplicações com Arquitetura Baseada em Microservices
Stars: ✭ 78 (-12.36%)
Mutual labels:  microservices-architecture
dotnet-core-microservices-kafka
Asp.Net Core microservices that communicate asynchronous through Kafka message broker.
Stars: ✭ 42 (-52.81%)
Mutual labels:  microservices-architecture
serverless-node-sequelize-rds-rest-api
Serverless rest api application with Node.js to perform simple CRUD operation using MYSQL database hosted on AWS RDS with Sequelize ORM
Stars: ✭ 43 (-51.69%)
Mutual labels:  microservices-architecture
okta-microservice-security-examples
Demos from Oktane18: API and Microservices Best Practices
Stars: ✭ 17 (-80.9%)
Mutual labels:  microservices-architecture
mean-ionic-ngrx
Monorepo as Microservices: Full MEAN stack with Angular 7, Ionic 4 and ReactiveX API (ngrx/Store + ngrx/Effects) + i18n/ngx-translate + Express NodeJS REST API servers micro-services + JWT Authentication + UnitTest/e2e exemple + Travis + DevOps scripts and many more...
Stars: ✭ 60 (-32.58%)
Mutual labels:  microservices-architecture
pgwire
PostgreSQL client library for Deno and Node.js that exposes all features of wire protocol.
Stars: ✭ 56 (-37.08%)
Mutual labels:  logical-replication
blogr-pve
Puppet provisioning of HA failover/cluster environment implemented in Proxmox Virtual Environment and Linux boxes.
Stars: ✭ 28 (-68.54%)
Mutual labels:  microservices-architecture
go-distsys
Distributed Systems programming examples in the Go programming language.
Stars: ✭ 101 (+13.48%)
Mutual labels:  microservices-architecture
cloud-espm-cloud-native
Enterprise Sales and Procurement Model (ESPM) Cloud Native is a project that showcases how an application can be made resilient by implementing resilience design patterns. This application is developed using Spring Boot framework and can be deployed locally as well as on SAP BTP, Cloud Foundry environment.
Stars: ✭ 29 (-67.42%)
Mutual labels:  microservices-architecture
acme-freight
Acme Freight's Logistics Wizard application is composed of several microservices, including three Cloud Foundry applications, LoopBack, API Connect, and multiple Cloud Function actions.
Stars: ✭ 43 (-51.69%)
Mutual labels:  microservices-architecture

WAL-Listener

License GitHub go.mod Go version GitHub tag (latest SemVer) Build Status Codecov

A service that helps implement the Event-driven architecture.

To maintain the consistency of data in the system, we will use transactional messaging - publishing events in a single transaction with a domain model change.

The service allows you to subscribe to changes in the PostgreSQL database using its logical decoding capability and publish them to the NATS Streaming server.

Logic of work

To receive events about data changes in our PostgreSQL DB   we use the standard logic decoding module (pgoutput) This module converts changes read from the WAL into a logical replication protocol.   And we already consume all this information on our side. Then we filter out only the events we need and publish them in the queue

Event publishing

NATS JetStream is used as a message broker. Service publishes the following structure. The name of the topic for subscription to receive messages is formed from the prefix of the topic, the name of the database and the name of the table prefix + schema_table.

{
	ID        uuid.UUID   # unique ID           
	Schema    string                 
	Table     string                 
	Action    string                 
	Data      map[string]any 
	EventTime time.Time   # commit time          
}

Messages are published to NATS (JetStream) at least once!

Filter configuration example

databases:
  filter:
    tables:
      users:
        - insert
        - update

This filter means that we only process events occurring with the users table, and in particular insert and update data.

Topic mapping

By default, output NATS topic name consist of prefix, DB schema, and DB table name, but if you want to send all update in one topic you should be configured the topic map:

  topicsMap:
      main_users: "notifier"
      main_customers: "notifier"

DB setting

You must make the following settings in the db configuration (postgresql.conf)

  • wal_level >= “logical”
  • max_replication_slots >= 1

The publication & slot created automatically when the service starts (for all tables and all actions). You can delete the default publication and create your own (name: wal-listener) with the necessary filtering conditions, and then the filtering will occur at the database level and not at the application level.

https://www.postgresql.org/docs/current/sql-createpublication.html

If you change the publication, do not forget to change the slot name or delete the current one.

Service configuration

listener:
  slotName: myslot_1
  refreshConnection: 30s
  heartbeatInterval: 10s
  filter:
    tables:
      seasons:
        - insert
        - update
  topicsMap:
      schema_table_name: "notifier"
logger:
  caller: false
  level: info
  format: json
database:
  host: localhost
  port: 5432
  name: my_db
  user: postgres
  password: postgres
  debug: false
nats:
  address: localhost:4222
  streamName: "wal_listener"
  topicPrefix: ""
monitoring:
 sentryDSN: "dsn string"
 promAddr: ":2112"

Docker

You can start the container from the project folder (configuration file is required)

Docker Hub

https://hub.docker.com/r/ihippik/wal-listener

Example

docker run -v $(pwd)/config.yml:/app/config.yml ihippik/wal-listener:tag
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].