Class PgUrlParser
java.lang.Object
io.github.mfvanek.pg.connection.host.PgUrlParser
Utility class for parsing and manipulating PostgreSQL connection URLs.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringbuildCommonUrlToPrimary(String firstPgUrl, String secondPgUrl) Constructs a common (joint) PostgreSQL URL for a primary server.static StringConstructs a common (joint) PostgreSQL URL for a primary server.static StringbuildCommonUrlToPrimary(Set<String> pgUrls) Constructs a common (joint) PostgreSQL URL for a primary server.static StringConstructs a common (joint) PostgreSQL URL for a primary server.Extracts host-port pairs and builds replica-compatible connection URLs for each host.
-
Field Details
-
URL_HEADER
Header prefix for PostgreSQL JDBC URLs.- See Also:
-
-
Method Details
-
extractNameWithPortAndUrlForEachHost
@Nonnull public static List<Map.Entry<String,String>> extractNameWithPortAndUrlForEachHost(@Nonnull String pgUrl) Extracts host-port pairs and builds replica-compatible connection URLs for each host.- Parameters:
pgUrl- the PostgreSQL connection URL; must be valid and non-blank.- Returns:
- a list of host-port pairs and corresponding replica-compatible URLs.
-
buildCommonUrlToPrimary
@Nonnull public static String buildCommonUrlToPrimary(@Nonnull String firstPgUrl, @Nonnull String secondPgUrl) Constructs a common (joint) PostgreSQL URL for a primary server.- Parameters:
firstPgUrl- a first PostgreSQL connection URL.secondPgUrl- a second PostgreSQL connection URL.- Returns:
- the constructed primary connection URL.
-
buildCommonUrlToPrimary
@Nonnull public static String buildCommonUrlToPrimary(@Nonnull String firstPgUrl, @Nonnull String secondPgUrl, @Nonnull Map<String, String> urlParameters) Constructs a common (joint) PostgreSQL URL for a primary server.- Parameters:
firstPgUrl- a first PostgreSQL connection URL.secondPgUrl- a second PostgreSQL connection URL.urlParameters- optional additional parameters to include in the URL.- Returns:
- the constructed primary connection URL.
-
buildCommonUrlToPrimary
Constructs a common (joint) PostgreSQL URL for a primary server.- Parameters:
pgUrls- a set of PostgreSQL connection URLs.- Returns:
- the constructed primary connection URL.
-
buildCommonUrlToPrimary
@Nonnull public static String buildCommonUrlToPrimary(@Nonnull Set<String> pgUrls, @Nonnull Map<String, String> urlParameters) Constructs a common (joint) PostgreSQL URL for a primary server.- Parameters:
pgUrls- a set of PostgreSQL connection URLs.urlParameters- optional additional parameters to include in the URL.- Returns:
- the constructed primary connection URL.
-