JDBC
jdbc:postgresql://node1,node2,node3/postgres?targetServerType=masterjdbc:postgresql://node1,node2,node3/postgres?targetServerType=preferSecondaryjdbc:postgresql://node1,node2,node3/postgres?targetServerType=preferSecondary&loadBalanceHosts=true
libpq starting from PostgreSQL 10:
postgresql://host1:port2,host2:port2/?target_session_attrs=read-write