timgit / pg-boss

Queueing jobs in Postgres from Node.js like a boss
MIT License
2.15k stars 160 forks source link

Specify multiple host connections for PostgreSQL / Database Fail-Over #447

Closed DamirAhm closed 5 months ago

DamirAhm commented 5 months ago

Problem

According to PostgreSQL documentation, it is possible in PostgreSQL to specify multiple hosts to connect to. I would like to use this option with pgboss as a part of a failover strategy (in conjunction with the target_session_attrs parameter). Unfortunately it seems that this is not possible at the moment as I'm getting TypeError: Invalid URL error while trying to pass something like URI below to connectionString.

postgresql://database:password@host1:5432,host2:5432/database?target_session_attrs=read-write

Suggested solution

Add a feature that allows you to insert multiple hosts in the database connection string separated by commas. This value could then be forwarded to the underlying PG connection string.