2025-10-06 19:35:47 +07:00
2025-10-06 15:29:51 +07:00
2025-10-06 15:29:51 +07:00
2025-10-06 19:17:59 +07:00
2025-10-06 15:29:51 +07:00
2025-10-06 15:29:51 +07:00
2025-10-06 15:29:51 +07:00
2025-10-06 15:29:51 +07:00
2025-10-06 19:35:47 +07:00

🧩 Watermill PostgreSQL Template

Template ini adalah boilerplate siap pakai untuk membangun sistem Publish / Subscribe (Event-driven) menggunakan Watermill dan PostgreSQL sebagai backend message store.

Cocok digunakan untuk:

  • Integrasi antar microservice (event-driven)
  • Streaming data dari sistem eksternal
  • Pengganti message broker seperti Kafka/RabbitMQ berbasis PostgreSQL
  • Middleware antar aplikasi HIS, klaim, billing, atau sistem logistik

🚀 Fitur Utama

Fitur Keterangan
⚙️ Watermill v1.3.x stable Versi stabil terbaru dengan dukungan PostgreSQL schema & offset adapter
🧱 Auto-create table Semua tabel watermill_<topic> dan watermill_offsets_<topic> dibuat otomatis
🔧 Konfigurasi lewat .env Semua koneksi & daftar topik diatur lewat environment variable
🧰 Makefile command Jalankan, build, atau buat tabel hanya dengan 1 perintah
📡 Contoh Publisher & Subscriber Sudah ada implementasi minimal yang langsung jalan
🐘 PostgreSQL ready Menggunakan driver lib/pq yang kompatibel dengan Watermill-SQL

📁 Struktur Folder

watermill-template/
├── cmd/
│   └── main.go               # Entry point aplikasi
├── internal/
│   ├── config/               # Loader file .env
│   ├── db/                   # Koneksi ke PostgreSQL
│   └── pubsub/               # Implementasi Watermill (publisher, subscriber, table helper)
├── .env.example              # Contoh konfigurasi environment
├── Makefile                  # Shortcut command untuk run, build, create-table
├── go.mod                    # Modul Go
├── go.sum                    # Dependency checksum
└── README.md                 # Dokumentasi proyek

⚙️ Setup Langkah Demi Langkah

1 Clone Repository & Install Dependency

git clone https://github.com/yourname/watermill-template.git
cd watermill-template
go mod tidy

cp .env.example .env

# PostgreSQL Connection
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=postgres
DB_NAME=middleware
DB_SSLMODE=disable

# Watermill Topics (comma separated)
WATERMILL_TOPICS=mdw_close_bill,mdw_claim_request,mdw_kd_inacbg,mdw_berkas

# Logger
LOG_DEBUG=false
Description
No description provided
Readme 241 KiB
Languages
Go 93.4%
Makefile 6.6%