Skip to content

Commit

Permalink
rebase to master
Browse files Browse the repository at this point in the history
  • Loading branch information
galen0624 committed Jan 29, 2020
1 parent c717cd3 commit 184bdb6
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 19 deletions.
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ type Consul struct {
ChecksRequired string
ServiceMonitors int
TLS ConsulTlS
PollingInterval time.Duration
PollInterval time.Duration
}

type Custom struct {
Expand All @@ -164,7 +164,7 @@ type Custom struct {
QueryParams string
Scheme string
CheckTLSSkipVerify bool
PollingInterval time.Duration
PollInterval time.Duration
NoRouteHTML string
Timeout time.Duration
}
Expand Down
4 changes: 2 additions & 2 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ var defaultConfig = &Config{
CheckTimeout: 3 * time.Second,
CheckScheme: "http",
ChecksRequired: "one",
PollingInterval: 0,
PollInterval: 0,
},
Custom: Custom{
Host: "",
Scheme: "https",
CheckTLSSkipVerify: false,
PollingInterval: 5,
PollInterval: 5,
NoRouteHTML: "",
Timeout: 10,
Path: "",
Expand Down
2 changes: 1 addition & 1 deletion config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func load(cmdline, environ, envprefix []string, props *properties.Properties) (c
f.StringVar(&cfg.Registry.Custom.NoRouteHTML, "registry.custom.noroutehtml", defaultConfig.Registry.Custom.NoRouteHTML, "path to file for HTML returned when no route is found")
f.BoolVar(&cfg.Registry.Custom.CheckTLSSkipVerify, "registry.custom.checkTLSSkipVerify", defaultConfig.Registry.Custom.CheckTLSSkipVerify, "custom back end check TLS verification")
f.DurationVar(&cfg.Registry.Custom.Timeout, "registry.custom.timeout", defaultConfig.Registry.Custom.Timeout, "timeout for API request to custom back end")
f.DurationVar(&cfg.Registry.Custom.PollingInterval, "registry.custom.pollinginterval", defaultConfig.Registry.Custom.PollingInterval, "polling interval for API request to custom back end")
f.DurationVar(&cfg.Registry.Custom.PollInterval, "registry.custom.pollinginterval", defaultConfig.Registry.Custom.PollInterval, "polling interval for API request to custom back end")
f.StringVar(&cfg.Registry.Custom.Path, "registry.custom.path", defaultConfig.Registry.Custom.Path, "custom back end path in the URL")
f.StringVar(&cfg.Registry.Custom.QueryParams, "registry.custom.queryparams", defaultConfig.Registry.Custom.QueryParams, "custom back end query parameters in the URL")

Expand Down
12 changes: 6 additions & 6 deletions config/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ func TestLoad(t *testing.T) {
{
args: []string{"-registry.custom.pollinginterval", "5s"},
cfg: func(cfg *Config) *Config {
cfg.Registry.Custom.PollingInterval = 5 * time.Second
cfg.Registry.Custom.PollInterval = 5 * time.Second
return cfg
},
},
Expand All @@ -724,13 +724,13 @@ func TestLoad(t *testing.T) {
return cfg
},
},
{
{
args: []string{"-registry.consul.register.pollinterval", "5s"},
cfg: func(cfg *Config) *Config {
cfg.Registry.Consul.PollingInterval = 5 * time.Second
return cfg
},
cfg: func(cfg *Config) *Config {
cfg.Registry.Consul.PollInterval = 5 * time.Second
return cfg
},
},
{
args: []string{"-log.access.format", "foobar"},
cfg: func(cfg *Config) *Config {
Expand Down
1 change: 0 additions & 1 deletion registry/consul/routecmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func (r routecmd) build() []string {
}
}


// generate route commands
var config []string
for _, tag := range routetags {
Expand Down
2 changes: 1 addition & 1 deletion registry/consul/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,4 @@ func (w *ServiceMonitor) serviceConfig(name string, passing map[string]bool) (co
config = append(config, cmds...)
}
return config
}
}
8 changes: 4 additions & 4 deletions registry/custom/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ func customRoutes(cfg *config.Custom, ch chan string) {
resp, err := client.Do(req)
if err != nil {
ch <- fmt.Sprintf("Error Sending HTTPs Request To Custom be - %s -%s", URL, err.Error())
time.Sleep(cfg.PollingInterval)
time.Sleep(cfg.PollInterval)
continue
}

if resp.StatusCode != 200 {
ch <- fmt.Sprintf("Error Non-200 return (%v) from -%s", resp.StatusCode, URL)
time.Sleep(cfg.PollingInterval)
time.Sleep(cfg.PollInterval)
continue
}
log.Printf("[DEBUG] Custom Registry begin decoding json %s \n", time.Now())
decoder := json.NewDecoder(resp.Body)
err = decoder.Decode(&Routes)
if err != nil {
ch <- fmt.Sprintf("Error decoding request - %s -%s", URL, err.Error())
time.Sleep(cfg.PollingInterval)
time.Sleep(cfg.PollInterval)
continue
}

Expand All @@ -75,7 +75,7 @@ func customRoutes(cfg *config.Custom, ch chan string) {
route.SetTable(t)
log.Printf("[DEBUG] Custom Registry table set complete %s \n", time.Now())
ch <- "OK"
time.Sleep(cfg.PollingInterval)
time.Sleep(cfg.PollInterval)

}

Expand Down
2 changes: 1 addition & 1 deletion registry/custom/custom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestCustomRoutes(t *testing.T) {
Path: "test",
Scheme: "http",
CheckTLSSkipVerify: false,
PollingInterval: 3 * time.Second,
PollInterval: 3 * time.Second,
Timeout: 3 * time.Second,
}

Expand Down
2 changes: 1 addition & 1 deletion route/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func (t Table) matchingHostNoGlob(req *http.Request) (hosts []string) {

for pattern := range t {
normpat := normalizeHost(pattern, req.TLS != nil)
if normpat == host {
if normpat == host {
hosts = append(hosts, strings.ToLower(pattern))
return
}
Expand Down

0 comments on commit 184bdb6

Please sign in to comment.