summaryrefslogtreecommitdiff
path: root/plugins/config/tests/plugin1.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-10-13 13:55:20 +0300
committerValery Piashchynski <[email protected]>2020-10-13 13:55:20 +0300
commit0dc44d54cfcc9dd3fa09a41136f35a9a8d26b994 (patch)
treeffcb65010bebe9f5b5436192979e64b2402a6ec0 /plugins/config/tests/plugin1.go
parent08d6b6b7f773f83b286cd48c1a0fbec9a62fb42b (diff)
Initial commit of RR 2.0v2.0.0-alpha1
Diffstat (limited to 'plugins/config/tests/plugin1.go')
-rw-r--r--plugins/config/tests/plugin1.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/plugins/config/tests/plugin1.go b/plugins/config/tests/plugin1.go
new file mode 100644
index 00000000..4e7a5317
--- /dev/null
+++ b/plugins/config/tests/plugin1.go
@@ -0,0 +1,54 @@
+package tests
+
+import (
+ "errors"
+ "time"
+
+ "github.com/temporalio/roadrunner-temporal/config"
+)
+
+// ReloadConfig is a Reload configuration point.
+type ReloadConfig struct {
+ Interval time.Duration
+ Patterns []string
+ Services map[string]ServiceConfig
+}
+
+type ServiceConfig struct {
+ Enabled bool
+ Recursive bool
+ Patterns []string
+ Dirs []string
+ Ignore []string
+}
+
+type Foo struct {
+ configProvider config.Provider
+}
+
+
+// Depends on S2 and DB (S3 in the current case)
+func (f *Foo) Init(p config.Provider) error {
+ f.configProvider = p
+ return nil
+}
+
+func (f *Foo) Serve() chan error {
+ 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.New("should be at least one pattern, but got 0")
+ }
+
+ return errCh
+}
+
+func (f *Foo) Stop() error {
+ return nil
+}