feat(db): add ApplicationName to connection configuration

* Introduced ApplicationName field to identify clients in DSN
* Set default ApplicationName to "ResolveSpec"
* Updated tests for ApplicationName handling in DSN
This commit is contained in:
Hein
2026-09-30 17:12:04 +02:00
parent 20ba8ed112
commit 2898b335f8
6 changed files with 64 additions and 0 deletions
+6
View File
@@ -123,6 +123,12 @@ func buildPGXConfig(cfg ConnectionConfig) (*pgx.ConnConfig, error) {
}
cc.DialFunc = newDialFunc(cfg.GetConnectTimeout())
// Also applies to caller-supplied DSNs that do not set application_name.
if name := cfg.GetApplicationName(); name != "" {
if _, set := cc.RuntimeParams["application_name"]; !set {
cc.RuntimeParams["application_name"] = name
}
}
if cfg.GetQueryTimeout() > 0 {
if _, set := cc.RuntimeParams["statement_timeout"]; !set {
cc.RuntimeParams["statement_timeout"] = fmt.Sprintf("%d", cfg.GetQueryTimeout().Milliseconds())