superfly / fly_postgres_elixir

Library for working with local read-replica postgres databases and performing writes through RPC calls to other nodes in the primary Fly.io region.
https://hex.pm/packages/fly_postgres
Apache License 2.0
104 stars 10 forks source link

use stored procedure for tracking LSN replication #30

Closed brainlid closed 2 years ago

brainlid commented 2 years ago

This is a significant update. Configuration for the library changed and should be migrated.

This creates a migration that creates a stored procedure in the database. The stored proc does faster loop checks for LSN replication. This reduces latency as we spend less time going over the network from the app server to the database.

In the application.ex, now a supervisor is registered which manages the processes needed for tracking requests to be notified of replication and actually checking with the database for replication updates.