isoos / postgresql-dart

Dart PostgreSQL driver: supports extended query format, binary protocol and statement reuse.
https://pub.dev/packages/postgres
BSD 3-Clause "New" or "Revised" License
129 stars 36 forks source link

Handle connection strings and failover? #49

Open kevinelliott opened 2 years ago

kevinelliott commented 2 years ago

Does the postgres library for dart support connection strings? Does it support multi-hosts connection strings or multi-host in general? Can it handle reconnection to a read-write node if failover occurs (such as w/ Citus pg-auto-failover, see: https://www.citusdata.com/blog/2021/02/12/reconnecting-your-app-after-a-postgres-failover/)?

The foundational Postgres library (libpq) does support these things, and it would be good to know if this library can be augmented to support the features.

isoos commented 2 years ago

Does the postgres library for dart support connection strings?

The related package postgres_pool does support some: https://pub.dev/documentation/postgres_pool/latest/postgres_pool/PgEndpoint/PgEndpoint.parse.html

(they will be eventually merged)

Does it support multi-hosts connection strings or multi-host in general?

I've implemented this in another related library: cockroachdb_pool, which was very useful for a project. I guess one could use it and implement a similar thing for asymmetrical postgres/citus layouts too: https://pub.dev/packages/cockroachdb_pool

The foundational Postgres library (libpq) does support these things, and it would be good to know if this library can be augmented to support the features.

I have plans for extending the features of the package, but in the past year or so I was really busy and couldn't find the time for it. If you are up for it, I'm happy to review and take PRs...

kevinelliott commented 2 years ago

I see, got it, so it looks like it doesn't yet support passing the attributes, or defining multiple hosts.

I am looking at migrating to CockroachDB later, but until then I have a multi-node failover cluster and need to define the hostname of the primary active node by hand. In production this is super painful when the primary goes down.