diff options
author | Wolfy-J <[email protected]> | 2020-02-23 14:14:05 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2020-02-23 14:14:05 +0300 |
commit | 9ef9dfed7928e9a96b9545074f8aeb1468fda46c (patch) | |
tree | a50850ed8d74cf72964ae755e7e4790c8694a043 /service/reload/config.go | |
parent | 6a23ccdcda44ea8d90eb174ce3aab99d6b67b495 (diff) |
- need batching
Diffstat (limited to 'service/reload/config.go')
-rw-r--r-- | service/reload/config.go | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/service/reload/config.go b/service/reload/config.go index 930f4dff..f33b5081 100644 --- a/service/reload/config.go +++ b/service/reload/config.go @@ -9,25 +9,32 @@ import ( // Config is a Reload configuration point. type Config struct { - // Enable or disable Reload extension, default disable. - Enabled bool // Interval is a global refresh interval Interval time.Duration + // Patterns is a global file patterns to watch. It will be applied to every directory in project Patterns []string + // Services is set of services which would be reloaded in case of FS changes Services map[string]ServiceConfig } type ServiceConfig struct { + // Enabled indicates that service must be watched, doest not required when any other option specified + Enabled bool + // Recursive is options to use nested files from root folder Recursive bool + // Patterns is per-service specific files to watch Patterns []string + // Dirs is per-service specific dirs which will be combined with Patterns Dirs []string + // Ignore is set of files which would not be watched Ignore []string + // service is a link to service to restart service *roadrunner.Controllable } @@ -37,29 +44,23 @@ func (c *Config) Hydrate(cfg service.Config) error { if err := cfg.Unmarshal(c); err != nil { return err } + return nil } // InitDefaults sets missing values to their default values. func (c *Config) InitDefaults() error { - return c.Valid() + c.Interval = time.Second + c.Patterns = []string{".php"} + + return nil } // Valid validates the configuration. func (c *Config) Valid() error { - if c.Enabled == true && c.Interval < time.Second { + if 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 } |