diff options
Diffstat (limited to 'service/http/config.go')
-rw-r--r-- | service/http/config.go | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/service/http/config.go b/service/http/config.go index 321072c5..26cede37 100644 --- a/service/http/config.go +++ b/service/http/config.go @@ -9,9 +9,6 @@ import ( // Config configures RoadRunner HTTP server. type Config struct { - // Enable enables http service. - Enable bool - // Address and port to handle as http server. Address string @@ -27,41 +24,32 @@ type Config struct { // Hydrate must populate Config values using given Config source. Must return error if Config is not valid. func (c *Config) Hydrate(cfg service.Config) error { - if err := cfg.Unmarshal(c); err != nil { - return err + if c.Workers == nil { + c.Workers = &roadrunner.ServerConfig{} } - if !c.Enable { - return nil + if c.Uploads == nil { + c.Uploads = &UploadsConfig{} } - if c.Workers != nil { - c.Workers.InitDefaults() - } + c.Uploads.InitDefaults() + c.Workers.InitDefaults() - if err := c.Valid(); err != nil { + if err := cfg.Unmarshal(c); err != nil { return err } c.Workers.UpscaleDurations() + if err := c.Valid(); err != nil { + return err + } + return nil } // Valid validates the configuration. func (c *Config) Valid() error { - if c.Uploads == nil { - return errors.New("mailformed uploads config") - } - - if c.Workers == nil { - return errors.New("mailformed workers config") - } - - if c.Workers.Pool == nil { - return errors.New("mailformed workers config (pool config is missing)") - } - if err := c.Workers.Pool.Valid(); err != nil { return err } |