diff options
Diffstat (limited to 'interfaces')
-rwxr-xr-x | interfaces/factory/factory.go | 22 | ||||
-rw-r--r-- | interfaces/informer/interface.go | 6 | ||||
-rw-r--r-- | interfaces/pool/pool.go | 1 | ||||
-rw-r--r-- | interfaces/server/interface.go | 8 |
4 files changed, 32 insertions, 5 deletions
diff --git a/interfaces/factory/factory.go b/interfaces/factory/factory.go new file mode 100755 index 00000000..036ff4e7 --- /dev/null +++ b/interfaces/factory/factory.go @@ -0,0 +1,22 @@ +package worker + +import ( + "context" + "os/exec" + + "github.com/spiral/roadrunner/v2/pkg/worker" +) + +// Factory is responsible of wrapping given command into tasks WorkerProcess. +type Factory interface { + // SpawnWorkerWithContext creates new WorkerProcess process based on given command with contex. + // Process must not be started. + SpawnWorkerWithContext(context.Context, *exec.Cmd) (worker.BaseProcess, error) + + // SpawnWorker creates new WorkerProcess process based on given command. + // Process must not be started. + SpawnWorker(*exec.Cmd) (worker.BaseProcess, error) + + // Close the factory and underlying connections. + Close(ctx context.Context) error +} diff --git a/interfaces/informer/interface.go b/interfaces/informer/interface.go index a8d32841..b975edd7 100644 --- a/interfaces/informer/interface.go +++ b/interfaces/informer/interface.go @@ -1,8 +1,10 @@ package informer -import "github.com/spiral/roadrunner/v2" +import ( + "github.com/spiral/roadrunner/v2/interfaces/worker" +) // Informer used to get workers from particular plugin or set of plugins type Informer interface { - Workers() []roadrunner.WorkerBase + Workers() []worker.BaseProcess } diff --git a/interfaces/pool/pool.go b/interfaces/pool/pool.go new file mode 100644 index 00000000..4eadf064 --- /dev/null +++ b/interfaces/pool/pool.go @@ -0,0 +1 @@ +package pool diff --git a/interfaces/server/interface.go b/interfaces/server/interface.go index 2dae30c5..c50848d7 100644 --- a/interfaces/server/interface.go +++ b/interfaces/server/interface.go @@ -4,7 +4,9 @@ import ( "context" "os/exec" - "github.com/spiral/roadrunner/v2" + "github.com/spiral/roadrunner/v2/interfaces/pool" + "github.com/spiral/roadrunner/v2/interfaces/worker" + poolImpl "github.com/spiral/roadrunner/v2/pkg/pool" ) type Env map[string]string @@ -12,6 +14,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) (roadrunner.WorkerBase, error) - NewWorkerPool(ctx context.Context, opt roadrunner.PoolConfig, env Env) (roadrunner.Pool, error) + NewWorker(ctx context.Context, env Env) (worker.BaseProcess, error) + NewWorkerPool(ctx context.Context, opt poolImpl.Config, env Env) (pool.Pool, error) } |