mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2026-10-06 21:36:28 +00:00
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:
@@ -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())
|
||||
|
||||
@@ -59,6 +59,7 @@ type ConnectionConfig interface {
|
||||
GetConnMaxLifetime() *time.Duration
|
||||
GetConnMaxIdleTime() *time.Duration
|
||||
GetReadPreference() string
|
||||
GetApplicationName() string
|
||||
GetRetryAttempts() int
|
||||
GetRetryDelay() time.Duration
|
||||
GetRetryMaxDelay() time.Duration
|
||||
|
||||
Reference in New Issue
Block a user