diff pkg/config/config.go @ 3161:6a44a89ffb51

SOAP: Added a globally configurable timeout (default 1min) till a SOAP request is canceled.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 06 May 2019 13:19:59 +0200
parents 19fc84a98479
children 659549608644
line wrap: on
line diff
--- a/pkg/config/config.go	Mon May 06 13:05:49 2019 +0200
+++ b/pkg/config/config.go	Mon May 06 13:19:59 2019 +0200
@@ -22,6 +22,7 @@
 	"time"
 
 	homedir "github.com/mitchellh/go-homedir"
+
 	"github.com/spf13/cobra"
 	"github.com/spf13/viper"
 
@@ -110,6 +111,11 @@
 // to be served to to the web client.
 func PublishedConfig() string { return viper.GetString("published-config") }
 
+// SOAPTimeout is the timeout till a SOAP request is canceled.
+func SOAPTimeout() time.Duration {
+	return viper.GetDuration("soap-timeout")
+}
+
 var (
 	proxyKeyOnce       sync.Once
 	proxyKey           []byte
@@ -229,6 +235,10 @@
 		fl.Bool(name, value, usage)
 		vbind(name)
 	}
+	d := func(name string, value time.Duration, usage string) {
+		fl.Duration(name, value, usage)
+		vbind(name)
+	}
 
 	strP("db-host", "H", "localhost", "host of the database")
 	uiP("db-port", "P", 5432, "port of the database")
@@ -273,6 +283,8 @@
 	str("schema-dirs", ".", "Directories to find XSD schema files in (recursive).")
 
 	str("published-config", "", "path to a config file served to client.")
+
+	d("soap-timeout", time.Minute, "Timeout till a SOAP request is canceled.")
 }
 
 var (