How chengchen/event-piper works
Project type and purpose
• This is a small, single-purpose event-streaming microservice written in Elixir/OTP. It listens to PostgreSQL NOTIFY events on the new_events channel, reads from the events table, and pushes Server-Sent Events (SSE) over HTTP to live subscribers. It also supports on-demand historical replay by querying the same table.
File structure
• Top-level:
• config/ – environment and release configs (dev, test, prod, releases)
• lib/event_piper.ex – the application entrypoint and supervision tree
• lib/api/api_router.ex – HTTP routing (Plug + Cowboy) and SSE endpoint
• lib/business/ – core event logic:
• repo.ex: database interaction layer (Postgrex or Ecto wrapper)
• event.ex: domain model for events
• event_listener.ex: PostgreSQL LISTEN/NOTIFY subscriber and dispatcher
• postgresql/schema.sql – table schema for events and trigger/channel setup
• Dockerfile, Makefile – containerization and build/test orchestration
• test/ – integration tests
• mix.exs – project dependencies (Plug, Cowboy, Postgrex, etc.)
README for additional insights
• It confirms the single-connection LISTEN/NOTIFY approach, SSE “push” API on /events, X-Consumer-Id header for subscriber segregation, and Last-Event-Id header for replay.