mirror of
https://github.com/hasura/graphql-engine.git
synced 2025-01-08 08:44:24 +03:00
69c238dc95
This is for local testing. Details are in the README. [DSF-218]: https://hasurahq.atlassian.net/browse/DSF-218?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8449 GitOrigin-RevId: 758aa9600fe79ed5c2917def3c86ac185267259e
52 lines
1.5 KiB
Markdown
52 lines
1.5 KiB
Markdown
# Testing PostgreSQL read replication
|
|
|
|
This provides a Docker Compose file that starts up a PostgreSQL primary server and a single read replica.
|
|
|
|
We can use this to test how the HGE Server and Console behave when communicating with a read replica.
|
|
|
|
## Starting and stopping
|
|
|
|
To start them, run the following from this directory:
|
|
|
|
docker compose up --wait
|
|
|
|
To stop them, run:
|
|
|
|
docker compose down
|
|
|
|
(Add `-v` to delete the data too.)
|
|
|
|
## Connecting
|
|
|
|
### Ports
|
|
|
|
To connect to the databases, you will need to get the ports.
|
|
|
|
The primary port can be found by running:
|
|
|
|
docker compose port postgres-primary 5432
|
|
|
|
The replica port can be found by running:
|
|
|
|
docker compose port postgres-replica 5432
|
|
|
|
Note that these ports may change if you restart the server.
|
|
|
|
### Credentials
|
|
|
|
The database username is `postgres`, and the password is `password`, for both the primary and the replica.
|
|
|
|
## Experimenting with the Hasura GraphQL Engine
|
|
|
|
Run HGE as follows:
|
|
|
|
cabal run graphql-engine:exe:graphql-engine -- \
|
|
--metadata-database-url="postgresql://postgres:password@$(docker compose --project-directory=server/test-manual/postgres-replicas port postgres-primary 5432)" \
|
|
serve \
|
|
--enable-console \
|
|
--console-assets-dir=$PWD/frontend/dist/apps/server-assets-console
|
|
|
|
Then run the following to get the replica database connection URL, and add it as the "default" data source.
|
|
|
|
echo "postgresql://postgres:password@$(docker compose --project-directory=server/test-manual/postgres-replicas port postgres-primary 5432)"
|