Allow PG*
env vars as an alternative to DATABASE_URL
#256
+150
−99
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Accept the standard set of
PG*
env vars as an alternative to databaseconfiguration (e.g.
PGHOST
,PGDATABASE
, etc.). This is mostly drivenby having done something similar for the CLI in [1], but was also
requested in #249. This turns out to be quite easy to do because pgx
does all the heavy lifting.
As noted in [1], a bonus of this is that it adds some additional
configuration options that aren't very easily doable right now, for
example around the use of an SSL certificate to connect to Postgres. We
get automatic support for these vars:
PGSSLCERT
PGSSLKEY
PGSSLROOTCERT
PGSSLPASSWORD
As part of this I also ended up rearranging some things in
main.go
.Not strongly married to this design, but the idea is to get it into a
place where we can write tests for it, which previously wasn't possible.
Fixes #249.
[1] riverqueue/river#702