summaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-01-23 19:51:15 -0500
committerWolfy-J <[email protected]>2018-01-23 19:51:15 -0500
commit78a42de837928cf7d10a1ae04d7e82e56d66e1e2 (patch)
tree8882b9a051bcc9c42328df583c0bb8c39a89591e /config.go
parentfa4bd78d9f7c5f74e8445374370927c742fc4e78 (diff)
API update
Diffstat (limited to 'config.go')
-rw-r--r--config.go40
1 files changed, 32 insertions, 8 deletions
diff --git a/config.go b/config.go
index e5d78d49..e48cefc2 100644
--- a/config.go
+++ b/config.go
@@ -1,19 +1,43 @@
package roadrunner
-import "time"
+import (
+ "fmt"
+ "time"
+)
// Config defines basic behaviour of worker creation and handling process.
type Config struct {
- // MaxWorkers defines how many sub-processes can be run at once. This value might be doubled by Balancer while hot-swap.
- MaxWorkers uint64
+ // NumWorkers defines how many sub-processes can be run at once. This value
+ // might be doubled by Swapper while hot-swap.
+ NumWorkers uint64
- // MaxExecutions defines how many executions is allowed for the worker until it's destruction. Set 1 to create new process
- // for each new task, 0 to let worker handle as many tasks as it can.
+ // MaxExecutions defines how many executions is allowed for the worker until
+ // it's destruction. set 1 to create new process for each new task, 0 to let
+ // worker handle as many tasks as it can.
MaxExecutions uint64
- // AllocateTimeout defines for how long pool will be waiting for a worker to be freed to handle the task.
+ // AllocateTimeout defines for how long pool will be waiting for a worker to
+ // be freed to handle the task.
AllocateTimeout time.Duration
- // DestroyOnError when set to true workers will be destructed after any JobError.
- DestroyOnError bool
+ // DestroyTimeout defines for how long pool should be waiting for worker to
+ // properly stop, if timeout reached worker will be killed.
+ DestroyTimeout time.Duration
+}
+
+// Valid returns error if config not valid
+func (cfg *Config) Valid() error {
+ if cfg.NumWorkers == 0 {
+ return fmt.Errorf("config.NumWorkers must be set")
+ }
+
+ if cfg.AllocateTimeout == 0 {
+ return fmt.Errorf("config.AllocateTimeout must be set")
+ }
+
+ if cfg.DestroyTimeout == 0 {
+ return fmt.Errorf("config.DestroyTimeout must be set")
+ }
+
+ return nil
}