summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-01-15 00:29:23 +0300
committerValery Piashchynski <[email protected]>2021-01-15 00:29:23 +0300
commitaff4d2c7a92ae014988b27b27069b15a971b6c36 (patch)
tree50dc6e22db7ff51b0fcf3cce0a45b7b739e1f300 /pkg
parent7542ae2d4c392290766405d31996378378aad975 (diff)
Viper doesn't support `yaml` structure tags, it uses mapstructure
instead
Diffstat (limited to 'pkg')
-rw-r--r--pkg/pool/config.go20
-rwxr-xr-xpkg/pool/static_pool.go2
2 files changed, 11 insertions, 11 deletions
diff --git a/pkg/pool/config.go b/pkg/pool/config.go
index acdd3d6f..e3e2d3cd 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 `yaml:"num_workers"`
+ NumWorkers int64 `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 int64 `yaml:"max_jobs"`
+ MaxJobs int64 `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 `yaml:"allocate_timeout"`
+ 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 `yaml:"destroy_timeout"`
+ DestroyTimeout time.Duration `mapstructure:"destroy_timeout"`
// Supervision config to limit worker and pool memory usage.
- Supervisor *SupervisorConfig `yaml:"supervisor"`
+ Supervisor *SupervisorConfig `mapstructure:"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 `yaml:"watch_tick"`
+ WatchTick uint64 `mapstructure:"watch_tick"`
// TTL defines maximum time worker is allowed to live.
- TTL uint64 `yaml:"ttl"`
+ TTL uint64 `mapstructure:"ttl"`
// IdleTTL defines maximum duration worker can spend in idle mode. Disabled when 0.
- IdleTTL uint64 `yaml:"idle_ttl"`
+ IdleTTL uint64 `mapstructure:"idle_ttl"`
// ExecTTL defines maximum lifetime per job.
- ExecTTL uint64 `yaml:"exec_ttl"`
+ ExecTTL uint64 `mapstructure:"exec_ttl"`
// MaxWorkerMemory limits memory per worker.
- MaxWorkerMemory uint64 `yaml:"max_worker_memory"`
+ MaxWorkerMemory uint64 `mapstructure:"max_worker_memory"`
}
// InitDefaults enables default config values.
diff --git a/pkg/pool/static_pool.go b/pkg/pool/static_pool.go
index bb53e121..7cac7b4d 100755
--- a/pkg/pool/static_pool.go
+++ b/pkg/pool/static_pool.go
@@ -54,7 +54,7 @@ type StaticPool struct {
// Initialize creates new worker pool and task multiplexer. StaticPool will initiate with one worker.
func Initialize(ctx context.Context, cmd Command, factory worker.Factory, cfg Config, options ...Options) (pool.Pool, error) {
- const op = errors.Op("Initialize")
+ const op = errors.Op("static pool initialize")
if factory == nil {
return nil, errors.E(op, errors.Str("no factory initialized"))
}