summaryrefslogtreecommitdiff
path: root/tests/plugins/config/plugin2.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-02-16 00:04:05 +0300
committerValery Piashchynski <[email protected]>2021-02-16 00:04:05 +0300
commit87b3130a95e2ff2904e7910f9bc87bc3020dbe27 (patch)
treecc08fda6ccdc56ec26b0ef39f2fa80d6b950086a /tests/plugins/config/plugin2.go
parentf8dd689d3b7c9f953d21775110f7d3182768cfba (diff)
Add support for flag overwriting
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'tests/plugins/config/plugin2.go')
-rwxr-xr-xtests/plugins/config/plugin2.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/plugins/config/plugin2.go b/tests/plugins/config/plugin2.go
new file mode 100755
index 00000000..0fea9007
--- /dev/null
+++ b/tests/plugins/config/plugin2.go
@@ -0,0 +1,50 @@
+package config
+
+import (
+ "github.com/spiral/errors"
+ "github.com/spiral/roadrunner/v2/plugins/config"
+)
+
+type Foo2 struct {
+ configProvider config.Configurer
+}
+
+// Depends on S2 and DB (S3 in the current case)
+func (f *Foo2) Init(p config.Configurer) error {
+ f.configProvider = p
+ return nil
+}
+
+func (f *Foo2) Serve() chan error {
+ const op = errors.Op("foo_plugin_serve")
+ errCh := make(chan error, 1)
+
+ r := &ReloadConfig{}
+ err := f.configProvider.UnmarshalKey("reload", r)
+ if err != nil {
+ errCh <- err
+ }
+
+ if len(r.Patterns) == 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:6061" {
+ errCh <- errors.E(op, errors.Str("RPC.Listen should be overwritten"))
+ return errCh
+ }
+
+ return errCh
+}
+
+func (f *Foo2) Stop() error {
+ return nil
+}