summaryrefslogtreecommitdiff
path: root/plugins/app/tests/plugin_2.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-10-28 16:05:39 +0300
committerGitHub <[email protected]>2020-10-28 16:05:39 +0300
commitde53c3ad12a8afb379610f87399373c4d0626ef6 (patch)
treed4ed0d2a879fc9515062b77fc54ec80e66cf0054 /plugins/app/tests/plugin_2.go
parent47a570c220a36ae7b770ea594a41637fa31fc8e8 (diff)
parent175c02e501a3b5110f8882599d5d033fde5bf81b (diff)
Merge pull request #378 from spiral/feature/loggingv2.0.0-alpha14
Feature/logging
Diffstat (limited to 'plugins/app/tests/plugin_2.go')
-rw-r--r--plugins/app/tests/plugin_2.go88
1 files changed, 88 insertions, 0 deletions
diff --git a/plugins/app/tests/plugin_2.go b/plugins/app/tests/plugin_2.go
new file mode 100644
index 00000000..fbb9ca11
--- /dev/null
+++ b/plugins/app/tests/plugin_2.go
@@ -0,0 +1,88 @@
+package tests
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "time"
+
+ "github.com/spiral/roadrunner/v2"
+ "github.com/spiral/roadrunner/v2/plugins/app"
+ "github.com/spiral/roadrunner/v2/plugins/config"
+)
+
+type Foo2 struct {
+ configProvider config.Provider
+ wf app.WorkerFactory
+}
+
+func (f *Foo2) Init(p config.Provider, workerFactory app.WorkerFactory) error {
+ f.configProvider = p
+ f.wf = workerFactory
+ return nil
+}
+
+func (f *Foo2) Serve() chan error {
+ errCh := make(chan error, 1)
+
+ r := &app.Config{}
+ err := f.configProvider.UnmarshalKey("app", r)
+ if err != nil {
+ errCh <- err
+ return errCh
+ }
+
+ cmd, err := f.wf.CmdFactory(nil)
+ if err != nil {
+ errCh <- err
+ return errCh
+ }
+ if cmd == nil {
+ errCh <- errors.New("command is nil")
+ return errCh
+ }
+ a := cmd()
+ out, err := a.Output()
+ if err != nil {
+ errCh <- err
+ return errCh
+ }
+
+ w, err := f.wf.NewWorker(context.Background(), nil)
+ if err != nil {
+ errCh <- err
+ return errCh
+ }
+
+ _ = w
+
+ poolConfig := roadrunner.Config{
+ NumWorkers: 10,
+ MaxJobs: 100,
+ AllocateTimeout: time.Second * 10,
+ DestroyTimeout: time.Second * 10,
+ Supervisor: &roadrunner.SupervisorConfig{
+ WatchTick: 60,
+ TTL: 1000,
+ IdleTTL: 10,
+ ExecTTL: 10,
+ MaxWorkerMemory: 1000,
+ },
+ }
+
+ pool, err := f.wf.NewWorkerPool(context.Background(), poolConfig, nil)
+ if err != nil {
+ errCh <- err
+ return errCh
+ }
+
+ _ = pool
+
+ fmt.Println(string(out))
+
+ return errCh
+}
+
+func (f *Foo2) Stop() error {
+ return nil
+}