diff options
author | Wolfy-J <[email protected]> | 2018-09-10 14:29:10 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-09-10 14:29:10 +0300 |
commit | 7ab1e77f2db902cf8a485e3a28bfdbd58a613dc9 (patch) | |
tree | 748253cb7d5b758a0b61ab4a88023e5fed4f4a3b /server_config.go | |
parent | ceb5033d5bb2fb641c886d4010f05498552152c2 (diff) |
go fmt
Diffstat (limited to 'server_config.go')
-rw-r--r-- | server_config.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/server_config.go b/server_config.go index 1a24e335..51f8245b 100644 --- a/server_config.go +++ b/server_config.go @@ -35,6 +35,10 @@ type ServerConfig struct { // SetDefaults sets missing values to their default values. func (cfg *ServerConfig) SetDefaults() { + if c.Workers.Relay == "" { + c.Workers.Relay = "pipes" + } + if cfg.RelayTimeout == 0 { cfg.RelayTimeout = time.Minute } @@ -48,6 +52,21 @@ func (cfg *ServerConfig) SetDefaults() { } } +// UpscaleDurations converts duration values from nanoseconds to seconds. +func (cfg *ServerConfig) UpscaleDurations() { + if cfg.RelayTimeout < time.Microsecond { + cfg.RelayTimeout = time.Second * time.Duration(cfg.RelayTimeout.Nanoseconds()) + } + + if cfg.Pool.AllocateTimeout < time.Microsecond { + cfg.Pool.AllocateTimeout = time.Second * time.Duration(cfg.Pool.AllocateTimeout.Nanoseconds()) + } + + if cfg.Pool.DestroyTimeout < time.Microsecond { + cfg.Pool.DestroyTimeout = time.Second * time.Duration(cfg.Pool.DestroyTimeout.Nanoseconds()) + } +} + // Differs returns true if configuration has changed but ignores pool or cmd changes. func (cfg *ServerConfig) Differs(new *ServerConfig) bool { return cfg.Relay != new.Relay || cfg.RelayTimeout != new.RelayTimeout |