summaryrefslogtreecommitdiff
path: root/plugins/server/config.go
blob: 00ce4140ddd1ead2791b41089805611f7bb9f052 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package server

import (
	"time"
)

// Config All config (.rr.yaml)
// For other section use pointer to distinguish between `empty` and `not present`
type Config struct {
	// Server config section
	Server struct {
		// Command to run as application.
		Command string `mapstructure:"command"`
		// User to run application under.
		User string `mapstructure:"user"`
		// Group to run application under.
		Group string `mapstructure:"group"`
		// Env represents application environment.
		Env Env `mapstructure:"env"`
		// Relay defines connection method and factory to be used to connect to workers:
		// "pipes", "tcp://:6001", "unix://rr.sock"
		// This config section must not change on re-configuration.
		Relay string `mapstructure:"relay"`
		// RelayTimeout defines for how long socket factory will be waiting for worker connection. This config section
		// must not change on re-configuration. Defaults to 60s.
		RelayTimeout time.Duration `mapstructure:"relay_timeout"`
	} `mapstructure:"server"`

	// we just need to know if the section exist, we don't need to read config from it
	RPC *struct {
		Listen string `mapstructure:"listen"`
	} `mapstructure:"rpc"`
	Logs *struct {
	} `mapstructure:"logs"`
	HTTP *struct {
	} `mapstructure:"http"`
	Redis *struct {
	} `mapstructure:"redis"`
	Boltdb *struct {
	} `mapstructure:"boltdb"`
	Memcached *struct {
	} `mapstructure:"memcached"`
	Memory *struct {
	} `mapstructure:"memory"`
	Metrics *struct {
	} `mapstructure:"metrics"`
	Reload *struct {
	} `mapstructure:"reload"`
}

// InitDefaults for the server config
func (cfg *Config) InitDefaults() {
	if cfg.Server.Relay == "" {
		cfg.Server.Relay = "pipes"
	}

	if cfg.Server.RelayTimeout == 0 {
		cfg.Server.RelayTimeout = time.Second * 60
	}
}