summaryrefslogtreecommitdiff
path: root/pool/config.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2022-01-15 12:08:20 +0300
committerValery Piashchynski <[email protected]>2022-01-15 12:08:20 +0300
commit5254c8eb27311e2a8a53a4c90c3829cf1238c563 (patch)
treeb51c9a4c1dd4c25adc511498ce0380a7078c5572 /pool/config.go
parent13609dd03dd0d2fa85b9fb850be787bf4e2ea67f (diff)
Repository content update
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'pool/config.go')
-rw-r--r--pool/config.go75
1 files changed, 0 insertions, 75 deletions
diff --git a/pool/config.go b/pool/config.go
deleted file mode 100644
index 3a058956..00000000
--- a/pool/config.go
+++ /dev/null
@@ -1,75 +0,0 @@
-package pool
-
-import (
- "runtime"
- "time"
-)
-
-// Config .. Pool config Configures the pool behavior.
-type Config struct {
- // Debug flag creates new fresh worker before every request.
- Debug bool
-
- // NumWorkers defines how many sub-processes can be run at once. This value
- // might be doubled by Swapper while hot-swap. Defaults to number of CPU cores.
- NumWorkers uint64 `mapstructure:"num_workers"`
-
- // MaxJobs 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.
- MaxJobs uint64 `mapstructure:"max_jobs"`
-
- // AllocateTimeout defines for how long pool will be waiting for a worker to
- // be freed to handle the task. Defaults to 60s.
- AllocateTimeout time.Duration `mapstructure:"allocate_timeout"`
-
- // DestroyTimeout defines for how long pool should be waiting for worker to
- // properly destroy, if timeout reached worker will be killed. Defaults to 60s.
- DestroyTimeout time.Duration `mapstructure:"destroy_timeout"`
-
- // Supervision config to limit worker and pool memory usage.
- Supervisor *SupervisorConfig `mapstructure:"supervisor"`
-}
-
-// InitDefaults enables default config values.
-func (cfg *Config) InitDefaults() {
- if cfg.NumWorkers == 0 {
- cfg.NumWorkers = uint64(runtime.NumCPU())
- }
-
- if cfg.AllocateTimeout == 0 {
- cfg.AllocateTimeout = time.Minute
- }
-
- if cfg.DestroyTimeout == 0 {
- cfg.DestroyTimeout = time.Minute
- }
- if cfg.Supervisor == nil {
- return
- }
- cfg.Supervisor.InitDefaults()
-}
-
-type SupervisorConfig struct {
- // WatchTick defines how often to check the state of worker.
- WatchTick time.Duration `mapstructure:"watch_tick"`
-
- // TTL defines maximum time worker is allowed to live.
- TTL time.Duration `mapstructure:"ttl"`
-
- // IdleTTL defines maximum duration worker can spend in idle mode. Disabled when 0.
- IdleTTL time.Duration `mapstructure:"idle_ttl"`
-
- // ExecTTL defines maximum lifetime per job.
- ExecTTL time.Duration `mapstructure:"exec_ttl"`
-
- // MaxWorkerMemory limits memory per worker.
- MaxWorkerMemory uint64 `mapstructure:"max_worker_memory"`
-}
-
-// InitDefaults enables default config values.
-func (cfg *SupervisorConfig) InitDefaults() {
- if cfg.WatchTick == 0 {
- cfg.WatchTick = time.Second
- }
-}