timgit / pg-boss

Queueing jobs in Node.js using PostgreSQL like a boss
MIT License
1.73k stars 144 forks source link

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

Closed DamirAhm closed 1 month ago

DamirAhm commented 1 month 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.