diff options
author | Valery Piashchynski <[email protected]> | 2020-02-21 18:02:33 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-02-21 18:02:33 +0300 |
commit | b2a19749a3e02f38c50e9023a22c60b679933c97 (patch) | |
tree | d192af0c58907ce110ab3bdcb1dd839196a02d8b /service/reload/config.go | |
parent | b44167f66258712df47c21896961756f8be672df (diff) |
Add tests
Add reload tests to Makefile
Remove old code
Diffstat (limited to 'service/reload/config.go')
-rw-r--r-- | service/reload/config.go | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/service/reload/config.go b/service/reload/config.go index 551fb71b..930f4dff 100644 --- a/service/reload/config.go +++ b/service/reload/config.go @@ -1,6 +1,7 @@ package reload import ( + "errors" "github.com/spiral/roadrunner" "github.com/spiral/roadrunner/service" "time" @@ -41,6 +42,24 @@ func (c *Config) Hydrate(cfg service.Config) error { // InitDefaults sets missing values to their default values. func (c *Config) InitDefaults() error { - c.Enabled = false + return c.Valid() +} + +// Valid validates the configuration. +func (c *Config) Valid() error { + if c.Enabled == true && c.Interval < time.Second { + return errors.New("too short interval") + } + + if c.Enabled { + if c.Services == nil { + return errors.New("should add at least 1 service") + } + + if len(c.Services) == 0 { + return errors.New("should add initialized config") + } + } + return nil } |