Behaviour like JDBC's "targetServerType" #2186
-
In JDBC, I can connect to a database and I can provide the targetServerType parameter. The JDBC docs explain this as:
It provides a way to configure a HA connection with two hosts, one acting as the primary and one as the secondary. When something is wrong with the primary, the client will automatically switch to the secondary. I know that multiple hosts can be provided in pgx config but there is seems to be no preference for host selection other than reachability. Has anyone implemented a behavior similar to this in pgx? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think |
Beta Was this translation helpful? Give feedback.
I think
Config.ValidateConnect
may be able to do what you want. It is used by pgx to mimic libpqtarget_session_attrs
forread-write
,read-only
,primary
,standby
, andprefer-standby
.