NodeSelector using system load metric (#94)

* use load when selecting nodes

* Apply suggestions from code review

Co-authored-by: David Zhao <david@davidzhao.com>

* sysload selector test

* wire nodeSelectorFromConfig

* fix tests

* Update pkg/routing/selectorsystemload_test.go

Co-authored-by: David Zhao <david@davidzhao.com>

* dz review: nits

Co-authored-by: David Zhao <david@davidzhao.com>
This commit is contained in:
Mathew Kamkar
2021-08-26 15:24:39 -07:00
committed by GitHub
co-authored by David Zhao
parent 0a9d12bc35
commit c437152e2b
12 changed files with 140 additions and 21 deletions
+21 -11
View File
@@ -18,17 +18,18 @@ var DefaultStunServers = []string{
}
type Config struct {
Port uint32 `yaml:"port"`
PrometheusPort uint32 `yaml:"prometheus_port"`
RTC RTCConfig `yaml:"rtc"`
Redis RedisConfig `yaml:"redis"`
Audio AudioConfig `yaml:"audio"`
Room RoomConfig `yaml:"room"`
TURN TURNConfig `yaml:"turn"`
WebHook WebHookConfig `yaml:"webhook"`
KeyFile string `yaml:"key_file"`
Keys map[string]string `yaml:"keys"`
LogLevel string `yaml:"log_level"`
Port uint32 `yaml:"port"`
PrometheusPort uint32 `yaml:"prometheus_port"`
RTC RTCConfig `yaml:"rtc"`
Redis RedisConfig `yaml:"redis"`
Audio AudioConfig `yaml:"audio"`
Room RoomConfig `yaml:"room"`
TURN TURNConfig `yaml:"turn"`
WebHook WebHookConfig `yaml:"webhook"`
NodeSelector NodeSelectorConfig `yaml:"node_selector"`
KeyFile string `yaml:"key_file"`
Keys map[string]string `yaml:"keys"`
LogLevel string `yaml:"log_level"`
Development bool `yaml:"development"`
}
@@ -106,6 +107,11 @@ type WebHookConfig struct {
APIKey string `yaml:"api_key"`
}
type NodeSelectorConfig struct {
Kind string `yaml:"kind"`
SysloadLimit float32 `yaml:"sysload_limit"`
}
func NewConfig(confString string, c *cli.Context) (*Config, error) {
// start with defaults
conf := &Config{
@@ -145,6 +151,10 @@ func NewConfig(confString string, c *cli.Context) (*Config, error) {
TURN: TURNConfig{
Enabled: false,
},
NodeSelector: NodeSelectorConfig{
Kind: "random",
SysloadLimit: 0.7,
},
Keys: map[string]string{},
}
if confString != "" {