set dial timeout in postgres connections
defaults to 5m.
concourse/concourse#1182
@@ -4,7 +4,9 @@ import (
"fmt"
"regexp"
"sort"
+ "strconv"
"strings"
+ "time"
)
type PostgresConfig struct {
@@ -23,6 +25,8 @@ type PostgresConfig struct {
ClientCert FileFlag `long:"client-cert" description:"Client cert file location."`
ClientKey FileFlag `long:"client-key" description:"Client key file location."`
+ ConnectTimeout time.Duration `long:"connect-timeout" description:"Dialing timeout. (0 means wait indefinitely)" default:"5m"`
+
Database string `long:"database" description:"The name of the database to use." default:"atc"`
}
@@ -63,6 +67,10 @@ func (config PostgresConfig) ConnectionString() string {
properties["sslkey"] = config.ClientKey.Path()
}
+ if config.ConnectTimeout != 0 {
+ properties["connect_timeout"] = strconv.Itoa(int(config.ConnectTimeout.Seconds()))
+ }
+
var pairs []string
for k, v := range properties {
var escV string
