Message-ID: From: "vlsi (@vlsi)" To: "pgjdbc/pgjdbc" Date: Fri, 07 Feb 2025 09:39:08 +0000 Subject: [pgjdbc/pgjdbc] issue #3514: Add PGConnection#getHost, PGConnection#getPort so clients could identify the current host for each connection List-Id: X-GitHub-Author-Id: 213894 X-GitHub-Author-Login: vlsi X-GitHub-Issue: 3514 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-State: open X-GitHub-Type: issue X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/3514 Content-Type: text/plain; charset=utf-8 **Describe the issue** See https://github.com/pgjdbc/pgjdbc/pull/3506. For monitoring and debugging purposes it might be helpful to identify the URL for a given connection. It might be tempting to expose `#getHost`, `#getPort` or `#getHostPort`, however, there might be cases like a connection over unix domain socket [which have no host and port parts](https://github.com/pgjdbc/r2dbc-postgresql/issues/181#issuecomment-1404648223). We might expose something like `URI PGConnection#getServerUri()`, however, it looks like there's no canonical way to map domain sockets to URL/URI: https://github.com/whatwg/url/issues/577 So we might be better to expose interface like `interface ConnectionSpec { String toString(); }` with a default implementation that we ship for regular socket connections like `interface InetAddressConnectionSpec implements ConnectionSpec { ..getHost(); getPort(); }`.