summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/server/config.go (renamed from plugins/app/config.go)10
-rw-r--r--plugins/server/plugin.go (renamed from plugins/app/plugin.go)22
-rw-r--r--plugins/server/tests/configs/.rr-no-app-section.yaml (renamed from plugins/app/tests/configs/.rr-no-app-section.yaml)2
-rw-r--r--plugins/server/tests/configs/.rr-sockets.yaml (renamed from plugins/app/tests/configs/.rr-sockets.yaml)2
-rw-r--r--plugins/server/tests/configs/.rr-tcp.yaml (renamed from plugins/app/tests/configs/.rr-tcp.yaml)2
-rw-r--r--plugins/server/tests/configs/.rr-wrong-command.yaml (renamed from plugins/app/tests/configs/.rr-wrong-command.yaml)2
-rw-r--r--plugins/server/tests/configs/.rr-wrong-relay.yaml (renamed from plugins/app/tests/configs/.rr-wrong-relay.yaml)2
-rw-r--r--plugins/server/tests/configs/.rr.yaml (renamed from plugins/app/tests/configs/.rr.yaml)2
-rw-r--r--plugins/server/tests/plugin_pipes.go (renamed from plugins/app/tests/plugin_pipes.go)11
-rw-r--r--plugins/server/tests/plugin_sockets.go (renamed from plugins/app/tests/plugin_sockets.go)9
-rw-r--r--plugins/server/tests/plugin_tcp.go (renamed from plugins/app/tests/plugin_tcp.go)9
-rw-r--r--plugins/server/tests/server_test.go (renamed from plugins/app/tests/app_test.go)16
-rw-r--r--plugins/server/tests/socket.php (renamed from plugins/app/tests/socket.php)0
-rw-r--r--plugins/server/tests/tcp.php (renamed from plugins/app/tests/tcp.php)0
14 files changed, 44 insertions, 45 deletions
diff --git a/plugins/app/config.go b/plugins/server/config.go
index eaa54e2d..147ae0f7 100644
--- a/plugins/app/config.go
+++ b/plugins/server/config.go
@@ -1,6 +1,10 @@
-package app
+package server
-import "time"
+import (
+ "time"
+
+ "github.com/spiral/roadrunner/v2/interfaces/server"
+)
// Config config combines factory, pool and cmd configurations.
type Config struct {
@@ -14,7 +18,7 @@ type Config struct {
Group string
// Env represents application environment.
- Env Env
+ Env server.Env
// Listen defines connection method and factory to be used to connect to workers:
// "pipes", "tcp://:6001", "unix://rr.sock"
diff --git a/plugins/app/plugin.go b/plugins/server/plugin.go
index ed2880cc..e096708a 100644
--- a/plugins/app/plugin.go
+++ b/plugins/server/plugin.go
@@ -1,4 +1,4 @@
-package app
+package server
import (
"context"
@@ -10,20 +10,12 @@ import (
"github.com/spiral/errors"
"github.com/spiral/roadrunner/v2"
"github.com/spiral/roadrunner/v2/interfaces/log"
+ "github.com/spiral/roadrunner/v2/interfaces/server"
"github.com/spiral/roadrunner/v2/plugins/config"
"github.com/spiral/roadrunner/v2/util"
)
-const ServiceName = "app"
-
-type Env map[string]string
-
-// WorkerFactory creates workers for the application.
-type WorkerFactory interface {
- CmdFactory(env Env) (func() *exec.Cmd, error)
- NewWorker(ctx context.Context, env Env) (roadrunner.WorkerBase, error)
- NewWorkerPool(ctx context.Context, opt roadrunner.Config, env Env) (roadrunner.Pool, error)
-}
+const ServiceName = "server"
// Plugin manages worker
type Plugin struct {
@@ -71,7 +63,7 @@ func (app *Plugin) Stop() error {
}
// CmdFactory provides worker command factory assocated with given context.
-func (app *Plugin) CmdFactory(env Env) (func() *exec.Cmd, error) {
+func (app *Plugin) CmdFactory(env server.Env) (func() *exec.Cmd, error) {
var cmdArgs []string
// create command according to the config
@@ -97,7 +89,7 @@ func (app *Plugin) CmdFactory(env Env) (func() *exec.Cmd, error) {
}
// NewWorker issues new standalone worker.
-func (app *Plugin) NewWorker(ctx context.Context, env Env) (roadrunner.WorkerBase, error) {
+func (app *Plugin) NewWorker(ctx context.Context, env server.Env) (roadrunner.WorkerBase, error) {
const op = errors.Op("new worker")
spawnCmd, err := app.CmdFactory(env)
if err != nil {
@@ -115,7 +107,7 @@ func (app *Plugin) NewWorker(ctx context.Context, env Env) (roadrunner.WorkerBas
}
// NewWorkerPool issues new worker pool.
-func (app *Plugin) NewWorkerPool(ctx context.Context, opt roadrunner.Config, env Env) (roadrunner.Pool, error) {
+func (app *Plugin) NewWorkerPool(ctx context.Context, opt roadrunner.PoolConfig, env server.Env) (roadrunner.Pool, error) {
spawnCmd, err := app.CmdFactory(env)
if err != nil {
return nil, err
@@ -159,7 +151,7 @@ func (app *Plugin) initFactory() (roadrunner.Factory, error) {
}
}
-func (app *Plugin) setEnv(e Env) []string {
+func (app *Plugin) setEnv(e server.Env) []string {
env := append(os.Environ(), fmt.Sprintf("RR_RELAY=%s", app.cfg.Relay))
for k, v := range e {
env = append(env, fmt.Sprintf("%s=%s", strings.ToUpper(k), v))
diff --git a/plugins/app/tests/configs/.rr-no-app-section.yaml b/plugins/server/tests/configs/.rr-no-app-section.yaml
index d129ae8a..b6e3ea93 100644
--- a/plugins/app/tests/configs/.rr-no-app-section.yaml
+++ b/plugins/server/tests/configs/.rr-no-app-section.yaml
@@ -1,4 +1,4 @@
-upp:
+server:
command: "php ../../../tests/client.php echo pipes"
user: ""
group: ""
diff --git a/plugins/app/tests/configs/.rr-sockets.yaml b/plugins/server/tests/configs/.rr-sockets.yaml
index 9bd62693..ab1239aa 100644
--- a/plugins/app/tests/configs/.rr-sockets.yaml
+++ b/plugins/server/tests/configs/.rr-sockets.yaml
@@ -1,4 +1,4 @@
-app:
+server:
command: "php socket.php"
user: ""
group: ""
diff --git a/plugins/app/tests/configs/.rr-tcp.yaml b/plugins/server/tests/configs/.rr-tcp.yaml
index c5a26d37..f53bffcc 100644
--- a/plugins/app/tests/configs/.rr-tcp.yaml
+++ b/plugins/server/tests/configs/.rr-tcp.yaml
@@ -1,4 +1,4 @@
-app:
+server:
command: "php tcp.php"
user: ""
group: ""
diff --git a/plugins/app/tests/configs/.rr-wrong-command.yaml b/plugins/server/tests/configs/.rr-wrong-command.yaml
index 4bd019d3..d2c087a6 100644
--- a/plugins/app/tests/configs/.rr-wrong-command.yaml
+++ b/plugins/server/tests/configs/.rr-wrong-command.yaml
@@ -1,4 +1,4 @@
-app:
+server:
command: "php some_absent_file.php"
user: ""
group: ""
diff --git a/plugins/app/tests/configs/.rr-wrong-relay.yaml b/plugins/server/tests/configs/.rr-wrong-relay.yaml
index d8ffe8f8..1dd73d73 100644
--- a/plugins/app/tests/configs/.rr-wrong-relay.yaml
+++ b/plugins/server/tests/configs/.rr-wrong-relay.yaml
@@ -1,4 +1,4 @@
-app:
+server:
command: "php ../../../tests/client.php echo pipes"
user: ""
group: ""
diff --git a/plugins/app/tests/configs/.rr.yaml b/plugins/server/tests/configs/.rr.yaml
index 221aff92..b6e3ea93 100644
--- a/plugins/app/tests/configs/.rr.yaml
+++ b/plugins/server/tests/configs/.rr.yaml
@@ -1,4 +1,4 @@
-app:
+server:
command: "php ../../../tests/client.php echo pipes"
user: ""
group: ""
diff --git a/plugins/app/tests/plugin_pipes.go b/plugins/server/tests/plugin_pipes.go
index fc999718..840021eb 100644
--- a/plugins/app/tests/plugin_pipes.go
+++ b/plugins/server/tests/plugin_pipes.go
@@ -6,14 +6,15 @@ import (
"github.com/spiral/errors"
"github.com/spiral/roadrunner/v2"
- "github.com/spiral/roadrunner/v2/plugins/app"
+ "github.com/spiral/roadrunner/v2/interfaces/server"
"github.com/spiral/roadrunner/v2/plugins/config"
+ plugin "github.com/spiral/roadrunner/v2/plugins/server"
)
const ConfigSection = "app"
const Response = "test"
-var testPoolConfig = roadrunner.Config{
+var testPoolConfig = roadrunner.PoolConfig{
NumWorkers: 10,
MaxJobs: 100,
AllocateTimeout: time.Second * 10,
@@ -29,11 +30,11 @@ var testPoolConfig = roadrunner.Config{
type Foo struct {
configProvider config.Configurer
- wf app.WorkerFactory
+ wf server.WorkerFactory
pool roadrunner.Pool
}
-func (f *Foo) Init(p config.Configurer, workerFactory app.WorkerFactory) error {
+func (f *Foo) Init(p config.Configurer, workerFactory server.WorkerFactory) error {
f.configProvider = p
f.wf = workerFactory
return nil
@@ -50,7 +51,7 @@ func (f *Foo) Serve() chan error {
errCh := make(chan error, 1)
- conf := &app.Config{}
+ conf := &plugin.Config{}
var err error
err = f.configProvider.UnmarshalKey(ConfigSection, conf)
if err != nil {
diff --git a/plugins/app/tests/plugin_sockets.go b/plugins/server/tests/plugin_sockets.go
index 585264f6..b12f4ead 100644
--- a/plugins/app/tests/plugin_sockets.go
+++ b/plugins/server/tests/plugin_sockets.go
@@ -5,17 +5,18 @@ import (
"github.com/spiral/errors"
"github.com/spiral/roadrunner/v2"
- "github.com/spiral/roadrunner/v2/plugins/app"
+ "github.com/spiral/roadrunner/v2/interfaces/server"
"github.com/spiral/roadrunner/v2/plugins/config"
+ plugin "github.com/spiral/roadrunner/v2/plugins/server"
)
type Foo2 struct {
configProvider config.Configurer
- wf app.WorkerFactory
+ wf server.WorkerFactory
pool roadrunner.Pool
}
-func (f *Foo2) Init(p config.Configurer, workerFactory app.WorkerFactory) error {
+func (f *Foo2) Init(p config.Configurer, workerFactory server.WorkerFactory) error {
f.configProvider = p
f.wf = workerFactory
return nil
@@ -25,7 +26,7 @@ func (f *Foo2) Serve() chan error {
const op = errors.Op("serve")
var err error
errCh := make(chan error, 1)
- conf := &app.Config{}
+ conf := &plugin.Config{}
// test payload for echo
r := roadrunner.Payload{
diff --git a/plugins/app/tests/plugin_tcp.go b/plugins/server/tests/plugin_tcp.go
index 6abc533d..39044577 100644
--- a/plugins/app/tests/plugin_tcp.go
+++ b/plugins/server/tests/plugin_tcp.go
@@ -5,17 +5,18 @@ import (
"github.com/spiral/errors"
"github.com/spiral/roadrunner/v2"
- "github.com/spiral/roadrunner/v2/plugins/app"
+ "github.com/spiral/roadrunner/v2/interfaces/server"
"github.com/spiral/roadrunner/v2/plugins/config"
+ plugin "github.com/spiral/roadrunner/v2/plugins/server"
)
type Foo3 struct {
configProvider config.Configurer
- wf app.WorkerFactory
+ wf server.WorkerFactory
pool roadrunner.Pool
}
-func (f *Foo3) Init(p config.Configurer, workerFactory app.WorkerFactory) error {
+func (f *Foo3) Init(p config.Configurer, workerFactory server.WorkerFactory) error {
f.configProvider = p
f.wf = workerFactory
return nil
@@ -25,7 +26,7 @@ func (f *Foo3) Serve() chan error {
const op = errors.Op("serve")
var err error
errCh := make(chan error, 1)
- conf := &app.Config{}
+ conf := &plugin.Config{}
// test payload for echo
r := roadrunner.Payload{
diff --git a/plugins/app/tests/app_test.go b/plugins/server/tests/server_test.go
index 3c416b59..53daa67f 100644
--- a/plugins/app/tests/app_test.go
+++ b/plugins/server/tests/server_test.go
@@ -7,7 +7,7 @@ import (
"time"
"github.com/spiral/endure"
- "github.com/spiral/roadrunner/v2/plugins/app"
+ "github.com/spiral/roadrunner/v2/plugins/server"
"github.com/spiral/roadrunner/v2/plugins/config"
"github.com/spiral/roadrunner/v2/plugins/logger"
"github.com/stretchr/testify/assert"
@@ -27,7 +27,7 @@ func TestAppPipes(t *testing.T) {
t.Fatal(err)
}
- err = container.Register(&app.Plugin{})
+ err = container.Register(&server.Plugin{})
if err != nil {
t.Fatal(err)
}
@@ -93,7 +93,7 @@ func TestAppSockets(t *testing.T) {
t.Fatal(err)
}
- err = container.Register(&app.Plugin{})
+ err = container.Register(&server.Plugin{})
if err != nil {
t.Fatal(err)
}
@@ -159,7 +159,7 @@ func TestAppTCP(t *testing.T) {
t.Fatal(err)
}
- err = container.Register(&app.Plugin{})
+ err = container.Register(&server.Plugin{})
if err != nil {
t.Fatal(err)
}
@@ -225,7 +225,7 @@ func TestAppWrongConfig(t *testing.T) {
t.Fatal(err)
}
- err = container.Register(&app.Plugin{})
+ err = container.Register(&server.Plugin{})
if err != nil {
t.Fatal(err)
}
@@ -257,7 +257,7 @@ func TestAppWrongRelay(t *testing.T) {
t.Fatal(err)
}
- err = container.Register(&app.Plugin{})
+ err = container.Register(&server.Plugin{})
if err != nil {
t.Fatal(err)
}
@@ -295,7 +295,7 @@ func TestAppWrongCommand(t *testing.T) {
t.Fatal(err)
}
- err = container.Register(&app.Plugin{})
+ err = container.Register(&server.Plugin{})
if err != nil {
t.Fatal(err)
}
@@ -333,7 +333,7 @@ func TestAppNoAppSectionInConfig(t *testing.T) {
t.Fatal(err)
}
- err = container.Register(&app.Plugin{})
+ err = container.Register(&server.Plugin{})
if err != nil {
t.Fatal(err)
}
diff --git a/plugins/app/tests/socket.php b/plugins/server/tests/socket.php
index 143c3ce4..143c3ce4 100644
--- a/plugins/app/tests/socket.php
+++ b/plugins/server/tests/socket.php
diff --git a/plugins/app/tests/tcp.php b/plugins/server/tests/tcp.php
index 2d6fb00a..2d6fb00a 100644
--- a/plugins/app/tests/tcp.php
+++ b/plugins/server/tests/tcp.php