summaryrefslogtreecommitdiff
path: root/plugins/jobs/drivers/beanstalk/config.go
blob: f05ee122cce884f9c0ee08e6d06f5cbe9f97eb8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package beanstalk

import "time"

type GlobalCfg struct {
	Addr    string        `mapstructure:"addr"`
	Timeout time.Duration `mapstructure:"timeout"`
}

func (c *GlobalCfg) InitDefault() {
	if c.Addr == "" {
		c.Addr = "tcp://localhost:11300"
	}

	if c.Timeout == 0 {
		c.Timeout = time.Second * 30
	}
}

type Config struct {
	PipePriority   int64         `mapstructure:"priority"`
	TubePriority   uint32        `mapstructure:"tube_priority"`
	Tube           string        `mapstructure:"tube"`
	ReserveTimeout time.Duration `mapstructure:"reserve_timeout"`
}

func (c *Config) InitDefault() {
	if c.Tube == "" {
		c.Tube = "default"
	}

	if c.ReserveTimeout == 0 {
		c.ReserveTimeout = time.Second * 5
	}

	if c.PipePriority == 0 {
		c.PipePriority = 10
	}
}