Add a reasonable application_name for PostgreSQL (#11048)

Signed-off-by: Alexander Sosna <alexander@sosna.de>
This commit is contained in:
Alexander 2021-05-10 18:56:47 +02:00 committed by GitHub
parent ee53fc5afb
commit d4b206ed4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -128,13 +128,19 @@ func (c *SQLConnectionProducer) Connection(ctx context.Context) (interface{}, er
// Otherwise, attempt to make connection
conn := c.ConnectionURL
// Ensure timezone is set to UTC for all the connections
// PostgreSQL specific settings
if strings.HasPrefix(conn, "postgres://") || strings.HasPrefix(conn, "postgresql://") {
// Ensure timezone is set to UTC for all the connections
if strings.Contains(conn, "?") {
conn += "&timezone=UTC"
} else {
conn += "?timezone=UTC"
}
// Ensure a reasonable application_name is set
if !strings.Contains(conn, "application_name") {
conn += "&application_name=vault"
}
}
var err error

View File

@ -128,13 +128,19 @@ func (c *SQLConnectionProducer) Connection(ctx context.Context) (interface{}, er
// Otherwise, attempt to make connection
conn := c.ConnectionURL
// Ensure timezone is set to UTC for all the connections
// PostgreSQL specific settings
if strings.HasPrefix(conn, "postgres://") || strings.HasPrefix(conn, "postgresql://") {
// Ensure timezone is set to UTC for all the connections
if strings.Contains(conn, "?") {
conn += "&timezone=UTC"
} else {
conn += "?timezone=UTC"
}
// Ensure a reasonable application_name is set
if !strings.Contains(conn, "application_name") {
conn += "&application_name=vault"
}
}
var err error