Swarm and db connection strings

We have a docker swarm setup across two host node machines (Node A, Node B). The service needs to be able to connect to the pgpool-ii (db) instance on their own respective host machines. If we provide a connection string into the service then the containers scheduled on each node will be using the same connection string so they would both connect to the pgpool-ii instance running only on Node A for example rather than the services running on node A connecting to the pgpool-ii on node A and the services on node B connecting to pgpool-ii on node B.

Would there be a way for example that I could provide a node label value of the IP which services needing db access on that node should use to connect to and the container running on that node would be able to get that value? I’m sure there is a better way of configuring it, any ideas?

(diagram attached)