summaryrefslogtreecommitdiff
path: root/plugins/config
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-03-31 18:58:03 +0300
committerValery Piashchynski <[email protected]>2021-03-31 18:58:03 +0300
commit955c6b7ca530172acc646c55e7e3eda04f543310 (patch)
treea816de47e7a1e5d6cabe836a30c7552e6023c3d2 /plugins/config
parentae6d488c9da200203c78af23518ea4f2f2e96773 (diff)
- Config: Add the ability to pass General config options to any plugin
Diffstat (limited to 'plugins/config')
-rw-r--r--plugins/config/config.go10
-rw-r--r--plugins/config/interface.go3
-rwxr-xr-xplugins/config/plugin.go7
3 files changed, 20 insertions, 0 deletions
diff --git a/plugins/config/config.go b/plugins/config/config.go
new file mode 100644
index 00000000..b5807921
--- /dev/null
+++ b/plugins/config/config.go
@@ -0,0 +1,10 @@
+package config
+
+import "time"
+
+// General is the part of the config plugin which contains general for the whole RR2 parameters
+// For example - http timeouts, headers sizes etc and also graceful shutdown timeout should be the same across whole application
+type General struct {
+ // GracefulTimeout for the temporal and http
+ GracefulTimeout time.Duration
+}
diff --git a/plugins/config/interface.go b/plugins/config/interface.go
index 23279f53..8370c0ab 100644
--- a/plugins/config/interface.go
+++ b/plugins/config/interface.go
@@ -23,4 +23,7 @@ type Configurer interface {
// Has checks if config section exists.
Has(name string) bool
+
+ // Returns General section. Read-only
+ GetCommonConfig() *General
}
diff --git a/plugins/config/plugin.go b/plugins/config/plugin.go
index a01a32b3..09fd35bb 100755
--- a/plugins/config/plugin.go
+++ b/plugins/config/plugin.go
@@ -19,6 +19,8 @@ type Viper struct {
// user defined Flags in the form of <option>.<key> = <value>
// which overwrites initial config key
Flags []string
+
+ CommonConfig *General
}
// Inits config provider.
@@ -111,6 +113,11 @@ func (v *Viper) Has(name string) bool {
return v.viper.IsSet(name)
}
+// Returns common config parameters
+func (v *Viper) GetCommonConfig() *General {
+ return v.CommonConfig
+}
+
func parseFlag(flag string) (string, string, error) {
const op = errors.Op("parse_flag")
if !strings.Contains(flag, "=") {