Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reformat the postgres connection URL to work properly with unix socke…
…t connections (Zondax#150) I ran into a problem trying to connect `namadexer` to a postgres database using a Unix domain socket rather than a network hostname. This is necessary in order to run the `server` in environments like Google Cloud Run, which exposes connections to Postgresql as a local domain socket. **The problem:** * Google Cloud SQL creates a socket with a path like `/cloudsql/namada:us-central1:namadexer-db-instance` * Setting `DATABASE_HOST=/cloudsql/namada:us-central1:namadexer-db-instance` would produce a connection URL like the following: ``` postgres://postgres:wow@/cloudsql/namada:my-region:namadexer-db-instance:5432/blockchain ``` * This URL is not valid. **The solution:** * There is an alternate form for the postgres URL, like this: ``` postgres://postgres:wow@dummy-hostname:5432/blockchain?host=/cloudsql/namada:my-region:namadexer-db-instance ``` * In this case, the actual `host` can contain `/` and `:` characters just fine. * The `dummy-hostname` in the host part of the URL must be present for the URL to be parsed properly, but is ignored.
- Loading branch information