Allow schema cache reloading with NOTIFY (#1542)

Fixes https://github.com/PostgREST/postgrest/issues/1512

Helps on environments where you can't send unix signals(Windows, managed
containers). Also provides better UX for schema reloads - NOTIFY
can be sent from pg clients(psql, pgadmin).

`NOTIFY pgrst` - with no payload - should be done to reload the schema cache.
Notifications with a payload will be ignored.

The channel can be enabled with `db-channel-enabled`(false by default)
and its name can be configured with `db-channel`.

The LISTEN thread uses a dedicated pg connection.
This connection is recovered if it fails.
A debounce of 1ms is done in case too many NOTIFYs arrive.
This commit is contained in:
Steve Chavez
2020-06-24 19:00:02 -05:00
committed by GitHub
parent 24064f8626
commit 43d71e95ac
13 changed files with 169 additions and 57 deletions
+13
View File
@@ -12,6 +12,19 @@ let
ver = "0.3.0";
sha256 = "0iwh4wsjhb7pms88lw1afhdal9f86nrrkkvv65f9wxbd1b159n72";
} { };
# To get the sha256
# nix-prefetch-url --unpack https://hackage.haskell.org/package/hasql-notifications-0.1.0.0/hasql-notifications-0.1.0.0.tar.gz
hasql-notifications =
self.haskell.lib.overrideCabal
(
prev.callHackageDirect
{
pkg = "hasql-notifications";
ver = "0.1.0.0";
sha256 = "1z17gsqvvzzi0yipc3qy3jz8vzpww4vsc4vaj2kbzr2mfliq6fx3";
} { }
)
(old: { doCheck = false; });
} // extraOverrides final prev;
in
{