diff options
author | Valery Piashchynski <[email protected]> | 2021-01-13 15:30:54 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2021-01-13 15:30:54 +0300 |
commit | 2a1c6092056c9dc1d725e393da97b72eb65071c4 (patch) | |
tree | 362f0eacdf2373bf208441577c1e69b8337bd71e /tests/plugins/config/plugin1.go | |
parent | f0f2b1aaf8e4df2ab65c6c47d9183f072ac86841 (diff) | |
parent | 2eed81d8fdbf8ee5134bb3b3f4c11c63cf6d757c (diff) |
Merge pull request #473 from spiral/feature/env_variables
feat(env): Add RR system environment variables
Diffstat (limited to 'tests/plugins/config/plugin1.go')
-rwxr-xr-x | tests/plugins/config/plugin1.go | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/tests/plugins/config/plugin1.go b/tests/plugins/config/plugin1.go index 2afe79a4..a6c06aec 100755 --- a/tests/plugins/config/plugin1.go +++ b/tests/plugins/config/plugin1.go @@ -1,12 +1,41 @@ package config import ( - "errors" "time" + "github.com/spiral/errors" "github.com/spiral/roadrunner/v2/plugins/config" ) +type AllConfig struct { + RPC struct { + Listen string `yaml:"listen"` + } `yaml:"rpc"` + Reload struct { + Enabled bool `yaml:"enabled"` + Interval string `yaml:"interval"` + Patterns []string `yaml:"patterns"` + Services struct { + HTTP struct { + Recursive bool `yaml:"recursive"` + Ignore []string `yaml:"ignore"` + Patterns []string `yaml:"patterns"` + Dirs []string `yaml:"dirs"` + } `yaml:"http"` + Jobs struct { + Recursive bool `yaml:"recursive"` + Ignore []string `yaml:"ignore"` + Dirs []string `yaml:"dirs"` + } `yaml:"jobs"` + RPC struct { + Recursive bool `yaml:"recursive"` + Patterns []string `yaml:"patterns"` + Dirs []string `yaml:"dirs"` + } `yaml:"rpc"` + } `yaml:"services"` + } `yaml:"reload"` +} + // ReloadConfig is a Reload configuration point. type ReloadConfig struct { Interval time.Duration @@ -33,6 +62,7 @@ func (f *Foo) Init(p config.Configurer) error { } func (f *Foo) Serve() chan error { + const op = errors.Op("foo serve") errCh := make(chan error, 1) r := &ReloadConfig{} @@ -42,7 +72,20 @@ func (f *Foo) Serve() chan error { } if len(r.Patterns) == 0 { - errCh <- errors.New("should be at least one pattern, but got 0") + errCh <- errors.E(op, errors.Str("should be at least one pattern, but got 0")) + return errCh + } + + var allCfg AllConfig + err = f.configProvider.Unmarshal(&allCfg) + if err != nil { + errCh <- errors.E(op, errors.Str("should be at least one pattern, but got 0")) + return errCh + } + + if allCfg.RPC.Listen != "tcp://localhost:6060" { + errCh <- errors.E(op, errors.Str("RPC.Listen should be parsed")) + return errCh } return errCh |