hapostgres / pg_auto_failover

Postgres extension and service for automated failover and high-availability
Other
1.07k stars 112 forks source link

How should I connect to the postgresql server #952

Closed lkgGitHub closed 1 year ago

lkgGitHub commented 1 year ago

I'll take a look at your tutorial, which uses psql to connect to the database.

I use go language to develop applications, and use xorm to connect to the database. It does not support sensing which service is the primary node.

Do pg_auto_failover have a way to database? Such as virtual ip?

DimCitus commented 1 year ago

When using Go, you can use the pgx driver which support multi-host and target-session-attrs since https://github.com/jackc/pgx/pull/545 3 years ago. See https://pkg.go.dev/github.com/jackc/pgx/v5#section-readme. Closing this issue, hoping that pgx indeed is an option for you.