diff options
author | Valery Piashchynski <[email protected]> | 2021-01-23 23:38:10 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-01-23 23:38:10 +0300 |
commit | 7fb3cc3588cfde9260a6bb431330ce1e0a71f56d (patch) | |
tree | 3200cf2136f7413a7e1cfc6ecdaa83716f9655f9 /plugins | |
parent | ee5d34abde7f3931bf939498eb7a8cb170232f4f (diff) |
interfaces folder deprecated
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/http/handler.go | 4 | ||||
-rw-r--r-- | plugins/http/plugin.go | 16 | ||||
-rw-r--r-- | plugins/informer/interface.go | 2 | ||||
-rw-r--r-- | plugins/informer/plugin.go | 2 | ||||
-rw-r--r-- | plugins/informer/rpc.go | 2 | ||||
-rw-r--r-- | plugins/server/interface.go | 8 | ||||
-rw-r--r-- | plugins/server/plugin.go | 17 |
7 files changed, 28 insertions, 23 deletions
diff --git a/plugins/http/handler.go b/plugins/http/handler.go index ecdcb2c0..0e7481b5 100644 --- a/plugins/http/handler.go +++ b/plugins/http/handler.go @@ -10,8 +10,8 @@ import ( "github.com/hashicorp/go-multierror" "github.com/spiral/errors" - "github.com/spiral/roadrunner/v2/interfaces/events" - "github.com/spiral/roadrunner/v2/interfaces/pool" + "github.com/spiral/roadrunner/v2/pkg/events" + "github.com/spiral/roadrunner/v2/pkg/pool" "github.com/spiral/roadrunner/v2/plugins/http/config" "github.com/spiral/roadrunner/v2/plugins/logger" ) diff --git a/plugins/http/plugin.go b/plugins/http/plugin.go index b1c68d89..144148af 100644 --- a/plugins/http/plugin.go +++ b/plugins/http/plugin.go @@ -15,9 +15,8 @@ import ( "github.com/hashicorp/go-multierror" endure "github.com/spiral/endure/pkg/container" "github.com/spiral/errors" - "github.com/spiral/roadrunner/v2/interfaces/pool" - "github.com/spiral/roadrunner/v2/interfaces/worker" - poolImpl "github.com/spiral/roadrunner/v2/pkg/pool" + "github.com/spiral/roadrunner/v2/pkg/pool" + "github.com/spiral/roadrunner/v2/pkg/worker" "github.com/spiral/roadrunner/v2/plugins/checker" "github.com/spiral/roadrunner/v2/plugins/config" "github.com/spiral/roadrunner/v2/plugins/http/attributes" @@ -104,7 +103,7 @@ func (s *Plugin) Init(cfg config.Configurer, log logger.Logger, server server.Se s.cfg.Env[RR_HTTP] = "true" - s.pool, err = server.NewWorkerPool(context.Background(), poolImpl.Config{ + s.pool, err = server.NewWorkerPool(context.Background(), pool.Config{ Debug: s.cfg.Pool.Debug, NumWorkers: s.cfg.Pool.NumWorkers, MaxJobs: s.cfg.Pool.MaxJobs, @@ -304,7 +303,12 @@ func (s *Plugin) ServeHTTP(w http.ResponseWriter, r *http.Request) { // Workers returns associated pool workers func (s *Plugin) Workers() []worker.BaseProcess { - return s.pool.Workers() + workers := s.pool.Workers() + baseWorkers := make([]worker.BaseProcess, 0, len(workers)) + for i := 0; i < len(workers); i++ { + baseWorkers = append(baseWorkers, worker.FromSync(workers[i])) + } + return baseWorkers } // Name returns endure.Named interface implementation @@ -322,7 +326,7 @@ func (s *Plugin) Reset() error { s.pool = nil var err error - s.pool, err = s.server.NewWorkerPool(context.Background(), poolImpl.Config{ + s.pool, err = s.server.NewWorkerPool(context.Background(), pool.Config{ Debug: s.cfg.Pool.Debug, NumWorkers: s.cfg.Pool.NumWorkers, MaxJobs: s.cfg.Pool.MaxJobs, diff --git a/plugins/informer/interface.go b/plugins/informer/interface.go index 27139ae1..8e3b922b 100644 --- a/plugins/informer/interface.go +++ b/plugins/informer/interface.go @@ -1,6 +1,6 @@ package informer -import "github.com/spiral/roadrunner/v2/interfaces/worker" +import "github.com/spiral/roadrunner/v2/pkg/worker" // Informer used to get workers from particular plugin or set of plugins type Informer interface { diff --git a/plugins/informer/plugin.go b/plugins/informer/plugin.go index 7200c51f..416c0112 100644 --- a/plugins/informer/plugin.go +++ b/plugins/informer/plugin.go @@ -3,7 +3,7 @@ package informer import ( endure "github.com/spiral/endure/pkg/container" "github.com/spiral/errors" - "github.com/spiral/roadrunner/v2/interfaces/worker" + "github.com/spiral/roadrunner/v2/pkg/worker" "github.com/spiral/roadrunner/v2/plugins/logger" ) diff --git a/plugins/informer/rpc.go b/plugins/informer/rpc.go index 98b5681c..c036ae96 100644 --- a/plugins/informer/rpc.go +++ b/plugins/informer/rpc.go @@ -1,7 +1,7 @@ package informer import ( - "github.com/spiral/roadrunner/v2/interfaces/worker" + "github.com/spiral/roadrunner/v2/pkg/worker" "github.com/spiral/roadrunner/v2/plugins/logger" "github.com/spiral/roadrunner/v2/tools" ) diff --git a/plugins/server/interface.go b/plugins/server/interface.go index a2d8b92b..fe04b85b 100644 --- a/plugins/server/interface.go +++ b/plugins/server/interface.go @@ -4,10 +4,10 @@ import ( "context" "os/exec" - "github.com/spiral/roadrunner/v2/interfaces/events" - "github.com/spiral/roadrunner/v2/interfaces/pool" - "github.com/spiral/roadrunner/v2/interfaces/worker" + "github.com/spiral/roadrunner/v2/pkg/events" + "github.com/spiral/roadrunner/v2/pkg/pool" poolImpl "github.com/spiral/roadrunner/v2/pkg/pool" + "github.com/spiral/roadrunner/v2/pkg/worker" ) // Env variables type alias @@ -16,6 +16,6 @@ type Env map[string]string // Server creates workers for the application. type Server interface { CmdFactory(env Env) (func() *exec.Cmd, error) - NewWorker(ctx context.Context, env Env, listeners ...events.Listener) (worker.BaseProcess, error) + NewWorker(ctx context.Context, env Env, listeners ...events.Listener) (*worker.Process, error) NewWorkerPool(ctx context.Context, opt poolImpl.Config, env Env, listeners ...events.Listener) (pool.Pool, error) } diff --git a/plugins/server/plugin.go b/plugins/server/plugin.go index 0c9c49ea..16123786 100644 --- a/plugins/server/plugin.go +++ b/plugins/server/plugin.go @@ -8,16 +8,17 @@ import ( "strings" "github.com/spiral/errors" + "github.com/spiral/roadrunner/v2/pkg/transport" "github.com/spiral/roadrunner/v2/plugins/config" "github.com/spiral/roadrunner/v2/plugins/logger" // core imports - "github.com/spiral/roadrunner/v2/interfaces/events" - "github.com/spiral/roadrunner/v2/interfaces/pool" - "github.com/spiral/roadrunner/v2/interfaces/worker" - "github.com/spiral/roadrunner/v2/pkg/pipe" + "github.com/spiral/roadrunner/v2/pkg/events" + "github.com/spiral/roadrunner/v2/pkg/pool" poolImpl "github.com/spiral/roadrunner/v2/pkg/pool" - "github.com/spiral/roadrunner/v2/pkg/socket" + "github.com/spiral/roadrunner/v2/pkg/transport/pipe" + "github.com/spiral/roadrunner/v2/pkg/transport/socket" + "github.com/spiral/roadrunner/v2/pkg/worker" "github.com/spiral/roadrunner/v2/utils" ) @@ -33,7 +34,7 @@ const RR_RPC = "RR_RPC" //nolint:golint,stylecheck type Plugin struct { cfg Config log logger.Logger - factory worker.Factory + factory transport.Factory } // Init application provider. @@ -115,7 +116,7 @@ func (server *Plugin) CmdFactory(env Env) (func() *exec.Cmd, error) { } // NewWorker issues new standalone worker. -func (server *Plugin) NewWorker(ctx context.Context, env Env, listeners ...events.Listener) (worker.BaseProcess, error) { +func (server *Plugin) NewWorker(ctx context.Context, env Env, listeners ...events.Listener) (*worker.Process, error) { const op = errors.Op("server_plugin_new_worker") list := make([]events.Listener, 0, len(listeners)) @@ -157,7 +158,7 @@ func (server *Plugin) NewWorkerPool(ctx context.Context, opt poolImpl.Config, en } // creates relay and worker factory. -func (server *Plugin) initFactory() (worker.Factory, error) { +func (server *Plugin) initFactory() (transport.Factory, error) { const op = errors.Op("server_plugin_init_factory") if server.cfg.Server.Relay == "" || server.cfg.Server.Relay == "pipes" { return pipe.NewPipeFactory(), nil |