summaryrefslogtreecommitdiff
path: root/pkg/pool
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-01-13 11:11:36 +0300
committerValery Piashchynski <[email protected]>2021-01-13 11:11:36 +0300
commitc3cf1d988b980e9408862d380f7ae33dae501e05 (patch)
tree79430ed15f75e23242e921a1471633e33279c395 /pkg/pool
parent44b0ad21e0d70e413a62814fb408faa033b0d478 (diff)
Update styly of the .rr.yaml
Add comments Add support for the automatically set RR_RPC, RR_HTTP env variables for the worker process.
Diffstat (limited to 'pkg/pool')
-rw-r--r--pkg/pool/config.go20
-rwxr-xr-xpkg/pool/supervisor_pool.go4
2 files changed, 12 insertions, 12 deletions
diff --git a/pkg/pool/config.go b/pkg/pool/config.go
index 3dcc3584..acdd3d6f 100644
--- a/pkg/pool/config.go
+++ b/pkg/pool/config.go
@@ -12,23 +12,23 @@ type Config struct {
// 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 int64
+ NumWorkers int64 `yaml:"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 int64
+ MaxJobs int64 `yaml:"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
+ AllocateTimeout time.Duration `yaml:"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
+ DestroyTimeout time.Duration `yaml:"destroy_timeout"`
// Supervision config to limit worker and pool memory usage.
- Supervisor *SupervisorConfig
+ Supervisor *SupervisorConfig `yaml:"supervisor"`
}
// InitDefaults enables default config values.
@@ -52,19 +52,19 @@ func (cfg *Config) InitDefaults() {
type SupervisorConfig struct {
// WatchTick defines how often to check the state of worker.
- WatchTick uint64
+ WatchTick uint64 `yaml:"watch_tick"`
// TTL defines maximum time worker is allowed to live.
- TTL uint64
+ TTL uint64 `yaml:"ttl"`
// IdleTTL defines maximum duration worker can spend in idle mode. Disabled when 0.
- IdleTTL uint64
+ IdleTTL uint64 `yaml:"idle_ttl"`
// ExecTTL defines maximum lifetime per job.
- ExecTTL uint64
+ ExecTTL uint64 `yaml:"exec_ttl"`
// MaxWorkerMemory limits memory per worker.
- MaxWorkerMemory uint64
+ MaxWorkerMemory uint64 `yaml:"max_worker_memory"`
}
// InitDefaults enables default config values.
diff --git a/pkg/pool/supervisor_pool.go b/pkg/pool/supervisor_pool.go
index 378be7dd..2e919eae 100755
--- a/pkg/pool/supervisor_pool.go
+++ b/pkg/pool/supervisor_pool.go
@@ -54,7 +54,7 @@ func (sp *supervised) ExecWithContext(ctx context.Context, rqs payload.Payload)
}
c := make(chan ttlExec, 1)
- ctx, cancel := context.WithTimeout(ctx, time.Second*time.Duration(sp.cfg.ExecTTL))
+ ctx, cancel := context.WithTimeout(ctx, time.Duration(sp.cfg.ExecTTL)*time.Second)
defer cancel()
go func() {
res, err := sp.pool.ExecWithContext(ctx, rqs)
@@ -114,7 +114,7 @@ func (sp *supervised) Destroy(ctx context.Context) {
func (sp *supervised) Start() {
go func() {
- watchTout := time.NewTicker(time.Second * time.Duration(sp.cfg.WatchTick))
+ watchTout := time.NewTicker(time.Duration(sp.cfg.WatchTick) * time.Second)
for {
select {
case <-sp.stopCh: