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.
When doing:
```
cabal upload dist-newstyle/sdist/postgrest-7.0.1.tar.gz
```
The following error is shown:
```
Error: Invalid package
'ghc-options: -Wall -Werror' makes the package very easy to break with
future GHC versions because new GHC versions often add new warnings.
Use just 'ghc-options: -Wall' instead. Alternatively, if you want to
use this, make it conditional based on a Cabal configuration flag
(with 'manual: True' and 'default: False') and enable that flag
during development.
```
Put -Werror in a cabal flag to work around this restriction.
The good part is that protolude 0.3.0 builds with GHC 8.10.
The bad part is that this change is a bit painful:
- the default `toS` has changed to no longer convert to and from ByteString
- similarly, `show` no longer outputs ByteString
The changes here are pretty much minimal to keep things compiling; I didn't
see a nice way to work with the new ConvertText class, even though `toUtf8`
seems like it might help if used besides `toS` at just the right spots.
The changes here are from fixing stack build with LTS 15.8 (GHC 8.8.3)
to be warning-free. Most if not all come from the newer protolude
version, which adds some things like `unwords`.
So to make sure that we don't get unused import warnings with newer
stackage, this both raises the protolude lower bound and removes
these imports.
* Don't indent first line of configuration parser error messages
configurator-pg returns multi-line errors now. Alternatively,
we could indent all the lines.
Two changes:
- tags are now an insert-ordered hashset
- type_ .~ -> type_ ?~ with some magic type inference
This also updates stack.yaml to the newest GHC 8.6 LTS release.
* Update resolver to lts-13.29 and add lock file to repository
* Upgrade stack version
* Save cache after building dependencies only to have faster feedback loop when tests fail
* Move private functions from QueryBuilder to a separate Private module
* Move more functions over to private trying to make compilation consume less memory
* Split private in 4 modules
* Remove unused LambdaCase pragma
* Add profile to memory-tests.sh so it can find postgrest executable
* Move save dependencies before building and running tests for faster feedback loop
See also https://github.com/haskell/cabal/issues/4739.
/Users/travis/build/PostgREST/postgrest/<built-in>:15:10: error:
error: non-portable path to file '".stack-work/dist/x86_64-osx/Cabal-2.2.0.1/build/PostgREST/autogen/cabal_macros.h"'; specified path differs in case from file name on disk [-Werror,-Wnonportable-include-path]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
".stack-work/dist/x86_64-osx/Cabal-2.2.0.1/build/PostgREST/autogen/cabal_macros.h"
* Update stack.yaml to lts-12.26 (GHC 8.4.4) with simplified nix config
(On GHC 8.6.5, profiled build was exiting with:
-- While building package postgrest-5.2.0 using:
/home/circleci/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5 --builddir=.stack-work/dist/x86_64-linux/Cabal-2.4.0.1 build lib:postgrest exe:postgrest --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
Process exited with code: ExitFailure (-9) (THIS MAY INDICATE OUT OF MEMORY)
Exited with code 1)
* stack.yaml: Add postgresql to nix packages
It was detected that Aeson encoding had high memory usage when
the json payload was large, around x60 the payload size.
With this change we get around x10 payload size memory usage.
The encodeUtf8(when doing a Text -> ByteString with `toS`) function
on a large payload also contributed to the high memory usage.
Main idea to reduce the memory usage was to let the ByteString coming
from the request body go to the database unchanged.
postgrest depends on postgres and zlib. When using stack's nix
integration, these dependencies must be specified explicitly.
Note that `--nix` must be passed to stack, or `nix.enable:true` must
be set in `stack.yaml` to enable using nix while building.
* Bring packages up to date
* New LTS includes deps now
Use stack to select most versions
* Alphabetize packages
* Strip down packages
Switch tests to protolude
* Appease cabal check with base version constraint