diff options
author | Valery Piashchynski <[email protected]> | 2020-10-27 15:16:55 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-10-27 15:16:55 +0300 |
commit | d199ef71b9644afbbba064c317cd0991be1c2443 (patch) | |
tree | f777eb90f10ca0e7dbc46227fc76c61f02111946 /pool.go | |
parent | 91cf918b30938129609323ded53e190385e019a6 (diff) |
Supervised pool
Diffstat (limited to 'pool.go')
-rwxr-xr-x | pool.go | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -54,6 +54,8 @@ type Pool interface { // Exec Exec(rqs Payload) (Payload, error) + ExecWithContext(ctx context.Context, rqs Payload) (Payload, error) + // Workers returns worker list associated with the pool. Workers() (workers []WorkerBase) @@ -84,7 +86,7 @@ type Config struct { DestroyTimeout time.Duration // Supervision config to limit worker and pool memory usage. - Supervisor SupervisorConfig + Supervisor *SupervisorConfig } // InitDefaults enables default config values. @@ -100,22 +102,24 @@ func (cfg *Config) InitDefaults() { 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 + WatchTick uint64 // TTL defines maximum time worker is allowed to live. - TTL int64 + TTL uint64 // IdleTTL defines maximum duration worker can spend in idle mode. Disabled when 0. - IdleTTL int64 + IdleTTL uint64 // ExecTTL defines maximum lifetime per job. - ExecTTL time.Duration + ExecTTL uint64 // MaxWorkerMemory limits memory per worker. MaxWorkerMemory uint64 @@ -124,6 +128,6 @@ type SupervisorConfig struct { // InitDefaults enables default config values. func (cfg *SupervisorConfig) InitDefaults() { if cfg.WatchTick == 0 { - cfg.WatchTick = time.Second + cfg.WatchTick = 1 } } |