diff options
Diffstat (limited to 'plugins/app/tests/plugin_1.go')
-rw-r--r-- | plugins/app/tests/plugin_1.go | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/plugins/app/tests/plugin_1.go b/plugins/app/tests/plugin_1.go new file mode 100644 index 00000000..7259ea9d --- /dev/null +++ b/plugins/app/tests/plugin_1.go @@ -0,0 +1,55 @@ +package tests + +import ( + "errors" + "fmt" + + "github.com/spiral/roadrunner/v2/plugins/app" + "github.com/spiral/roadrunner/v2/plugins/config" +) + +type Foo struct { + configProvider config.Provider + spawner app.WorkerFactory +} + +func (f *Foo) Init(p config.Provider, spw app.WorkerFactory) error { + f.configProvider = p + f.spawner = spw + return nil +} + +func (f *Foo) 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.spawner.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 + } + + fmt.Println(string(out)) + + return errCh +} + +func (f *Foo) Stop() error { + return nil +} |