summaryrefslogtreecommitdiff
path: root/interfaces
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-12-21 14:24:45 +0300
committerGitHub <[email protected]>2020-12-21 14:24:45 +0300
commit8543980775e5f8b12e5e200a0764052cdb4350a5 (patch)
treec1c6dff8e6bd81bcf51d608c5ed935702911ae81 /interfaces
parentfd6e9cc403fc0c3857dcf29768429a374bd85636 (diff)
parent7b32b6b93576ec72b4b7fdf2068e655f869e9cf8 (diff)
Merge pull request #453 from spiral/plugin/redis
Plugin/redis
Diffstat (limited to 'interfaces')
-rwxr-xr-xinterfaces/config/interface.go22
-rwxr-xr-xinterfaces/factory/factory.go22
-rw-r--r--interfaces/pool/pool.go3
-rw-r--r--interfaces/redis/interface.go9
-rw-r--r--interfaces/worker/factory.go4
-rw-r--r--interfaces/worker/worker.go4
6 files changed, 37 insertions, 27 deletions
diff --git a/interfaces/config/interface.go b/interfaces/config/interface.go
new file mode 100755
index 00000000..2a7c67ce
--- /dev/null
+++ b/interfaces/config/interface.go
@@ -0,0 +1,22 @@
+package config
+
+type Configurer interface {
+ // UnmarshalKey reads configuration section into configuration object.
+ //
+ // func (h *HttpService) Init(cp config.Configurer) error {
+ // h.config := &HttpConfig{}
+ // if err := configProvider.UnmarshalKey("http", h.config); err != nil {
+ // return err
+ // }
+ // }
+ UnmarshalKey(name string, out interface{}) error
+
+ // Get used to get config section
+ Get(name string) interface{}
+
+ // Overwrite used to overwrite particular values in the unmarshalled config
+ Overwrite(values map[string]interface{}) error
+
+ // Has checks if config section exists.
+ Has(name string) bool
+}
diff --git a/interfaces/factory/factory.go b/interfaces/factory/factory.go
deleted file mode 100755
index 51b73501..00000000
--- a/interfaces/factory/factory.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package worker
-
-import (
- "context"
- "os/exec"
-
- "github.com/spiral/roadrunner/v2/interfaces/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/pool/pool.go b/interfaces/pool/pool.go
index 72da9597..22552388 100644
--- a/interfaces/pool/pool.go
+++ b/interfaces/pool/pool.go
@@ -18,9 +18,10 @@ type Pool interface {
// GetConfig returns pool configuration.
GetConfig() interface{}
- // Exec
+ // Exec executes task with payload
Exec(rqs payload.Payload) (payload.Payload, error)
+ // ExecWithContext executes task with context which is used with timeout
ExecWithContext(ctx context.Context, rqs payload.Payload) (payload.Payload, error)
// Workers returns worker list associated with the pool.
diff --git a/interfaces/redis/interface.go b/interfaces/redis/interface.go
new file mode 100644
index 00000000..909c8ca4
--- /dev/null
+++ b/interfaces/redis/interface.go
@@ -0,0 +1,9 @@
+package redis
+
+import "github.com/go-redis/redis/v8"
+
+// Redis in the redis KV plugin interface
+type Redis interface {
+ // GetClient
+ GetClient() redis.UniversalClient
+}
diff --git a/interfaces/worker/factory.go b/interfaces/worker/factory.go
index 19e2bf5d..8db8ddcc 100644
--- a/interfaces/worker/factory.go
+++ b/interfaces/worker/factory.go
@@ -9,10 +9,10 @@ import (
type Factory interface {
// SpawnWorkerWithContext creates new WorkerProcess process based on given command with context.
// Process must not be started.
- SpawnWorkerWithContext(context.Context, *exec.Cmd) (BaseProcess, error)
+ SpawnWorkerWithTimeout(context.Context, *exec.Cmd) (BaseProcess, error)
// SpawnWorker creates new WorkerProcess process based on given command.
// Process must not be started.
SpawnWorker(*exec.Cmd) (BaseProcess, error)
// Close the factory and underlying connections.
- Close(ctx context.Context) error
+ Close() error
}
diff --git a/interfaces/worker/worker.go b/interfaces/worker/worker.go
index f830fdf2..7f2f8a53 100644
--- a/interfaces/worker/worker.go
+++ b/interfaces/worker/worker.go
@@ -40,7 +40,7 @@ type BaseProcess interface {
Wait() error
// Stop sends soft termination command to the WorkerProcess and waits for process completion.
- Stop(ctx context.Context) error
+ Stop() error
// Kill kills underlying process, make sure to call Wait() func to gather
// error log from the stderr. Does not waits for process completion!
@@ -59,5 +59,5 @@ type SyncWorker interface {
// Exec used to execute payload on the SyncWorker, there is no TIMEOUTS
Exec(rqs payload.Payload) (payload.Payload, error)
// ExecWithContext used to handle Exec with TTL
- ExecWithContext(ctx context.Context, p payload.Payload) (payload.Payload, error)
+ ExecWithTimeout(ctx context.Context, p payload.Payload) (payload.Payload, error)
}