go fmt
This commit is contained in:
@@ -81,9 +81,9 @@ func buildTree() *Node {
|
|||||||
setDisabled := &Node{Word: "disabled", Help: "disable backend (not implemented)", Run: runNotImplemented}
|
setDisabled := &Node{Word: "disabled", Help: "disable backend (not implemented)", Run: runNotImplemented}
|
||||||
setEnabled := &Node{Word: "enabled", Help: "enable backend (not implemented)", Run: runNotImplemented}
|
setEnabled := &Node{Word: "enabled", Help: "enable backend (not implemented)", Run: runNotImplemented}
|
||||||
setBackendName := &Node{
|
setBackendName := &Node{
|
||||||
Word: "<name>",
|
Word: "<name>",
|
||||||
Help: "backend name",
|
Help: "backend name",
|
||||||
Dynamic: dynBackends,
|
Dynamic: dynBackends,
|
||||||
Children: []*Node{setPause, setResume, setDisabled, setEnabled},
|
Children: []*Node{setPause, setResume, setDisabled, setEnabled},
|
||||||
}
|
}
|
||||||
setBackend := &Node{
|
setBackend := &Node{
|
||||||
|
|||||||
@@ -86,10 +86,10 @@ type rawConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type rawMaglev struct {
|
type rawMaglev struct {
|
||||||
HealthChecker rawHealthCheckerCfg `yaml:"healthchecker"`
|
HealthChecker rawHealthCheckerCfg `yaml:"healthchecker"`
|
||||||
HealthChecks map[string]rawHealthCheck `yaml:"healthchecks"`
|
HealthChecks map[string]rawHealthCheck `yaml:"healthchecks"`
|
||||||
Backends map[string]rawBackend `yaml:"backends"`
|
Backends map[string]rawBackend `yaml:"backends"`
|
||||||
Frontends map[string]rawFrontend `yaml:"frontends"`
|
Frontends map[string]rawFrontend `yaml:"frontends"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type rawHealthCheckerCfg struct {
|
type rawHealthCheckerCfg struct {
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ func TestGetFrontend(t *testing.T) {
|
|||||||
client, cleanup := startTestServer(t, ctx, c)
|
client, cleanup := startTestServer(t, ctx, c)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
info, err := client.GetFrontend(ctx, &GetFrontendRequest{Name:"web"})
|
info, err := client.GetFrontend(ctx, &GetFrontendRequest{Name: "web"})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("GetFrontend: %v", err)
|
t.Fatalf("GetFrontend: %v", err)
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ func TestGetFrontendNotFound(t *testing.T) {
|
|||||||
client, cleanup := startTestServer(t, ctx, c)
|
client, cleanup := startTestServer(t, ctx, c)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
_, err := client.GetFrontend(ctx, &GetFrontendRequest{Name:"nope"})
|
_, err := client.GetFrontend(ctx, &GetFrontendRequest{Name: "nope"})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("expected error for unknown frontend")
|
t.Error("expected error for unknown frontend")
|
||||||
}
|
}
|
||||||
@@ -152,7 +152,7 @@ func TestGetBackend(t *testing.T) {
|
|||||||
client, cleanup := startTestServer(t, ctx, c)
|
client, cleanup := startTestServer(t, ctx, c)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
info, err := client.GetBackend(ctx, &GetBackendRequest{Name:"be0"})
|
info, err := client.GetBackend(ctx, &GetBackendRequest{Name: "be0"})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("GetBackend: %v", err)
|
t.Fatalf("GetBackend: %v", err)
|
||||||
}
|
}
|
||||||
@@ -178,7 +178,7 @@ func TestGetBackendNotFound(t *testing.T) {
|
|||||||
client, cleanup := startTestServer(t, ctx, c)
|
client, cleanup := startTestServer(t, ctx, c)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
_, err := client.GetBackend(ctx, &GetBackendRequest{Name:"nope"})
|
_, err := client.GetBackend(ctx, &GetBackendRequest{Name: "nope"})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("expected error for unknown backend")
|
t.Error("expected error for unknown backend")
|
||||||
}
|
}
|
||||||
@@ -192,7 +192,7 @@ func TestPauseResumeBackend(t *testing.T) {
|
|||||||
client, cleanup := startTestServer(t, ctx, c)
|
client, cleanup := startTestServer(t, ctx, c)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
info, err := client.PauseBackend(ctx, &PauseResumeRequest{Name:"be0"})
|
info, err := client.PauseBackend(ctx, &PauseResumeRequest{Name: "be0"})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("PauseBackend: %v", err)
|
t.Fatalf("PauseBackend: %v", err)
|
||||||
}
|
}
|
||||||
@@ -200,7 +200,7 @@ func TestPauseResumeBackend(t *testing.T) {
|
|||||||
t.Errorf("after pause: got %q, want paused", info.State)
|
t.Errorf("after pause: got %q, want paused", info.State)
|
||||||
}
|
}
|
||||||
|
|
||||||
info, err = client.ResumeBackend(ctx, &PauseResumeRequest{Name:"be0"})
|
info, err = client.ResumeBackend(ctx, &PauseResumeRequest{Name: "be0"})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("ResumeBackend: %v", err)
|
t.Fatalf("ResumeBackend: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -253,14 +253,14 @@ func TestTransitionHistory(t *testing.T) {
|
|||||||
maxHistory := 3
|
maxHistory := 3
|
||||||
|
|
||||||
// Drive several state changes. Each cycle: pass×2→Up, fail→Down (Unknown→Down on first fail).
|
// Drive several state changes. Each cycle: pass×2→Up, fail→Down (Unknown→Down on first fail).
|
||||||
b.Record(fail(), maxHistory) // Unknown→Down
|
b.Record(fail(), maxHistory) // Unknown→Down
|
||||||
b.Record(pass(), maxHistory) // counter++
|
b.Record(pass(), maxHistory) // counter++
|
||||||
b.Record(pass(), maxHistory) // Down→Up
|
b.Record(pass(), maxHistory) // Down→Up
|
||||||
b.Record(fail(), maxHistory) // Up: counter drops
|
b.Record(fail(), maxHistory) // Up: counter drops
|
||||||
b.Record(fail(), maxHistory) // Up: counter drops
|
b.Record(fail(), maxHistory) // Up: counter drops
|
||||||
b.Record(fail(), maxHistory) // Up→Down
|
b.Record(fail(), maxHistory) // Up→Down
|
||||||
b.Record(pass(), maxHistory) // counter++
|
b.Record(pass(), maxHistory) // counter++
|
||||||
b.Record(pass(), maxHistory) // Down→Up
|
b.Record(pass(), maxHistory) // Down→Up
|
||||||
|
|
||||||
if len(b.Transitions) != maxHistory {
|
if len(b.Transitions) != maxHistory {
|
||||||
t.Errorf("transitions capped at %d, got %d", maxHistory, len(b.Transitions))
|
t.Errorf("transitions capped at %d, got %d", maxHistory, len(b.Transitions))
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ type ProbeFunc func(ctx context.Context, cfg ProbeConfig) health.ProbeResult
|
|||||||
|
|
||||||
// ProbeConfig holds all parameters needed to execute a single probe.
|
// ProbeConfig holds all parameters needed to execute a single probe.
|
||||||
type ProbeConfig struct {
|
type ProbeConfig struct {
|
||||||
Target net.IP // backend address to probe
|
Target net.IP // backend address to probe
|
||||||
Port uint16 // destination port (used by TCP and HTTP probers)
|
Port uint16 // destination port (used by TCP and HTTP probers)
|
||||||
ProbeSrc net.IP // source address to bind; nil lets the OS choose
|
ProbeSrc net.IP // source address to bind; nil lets the OS choose
|
||||||
HealthCheckNetns string // network namespace name; sockets are created inside it
|
HealthCheckNetns string // network namespace name; sockets are created inside it
|
||||||
Timeout time.Duration
|
Timeout time.Duration
|
||||||
HTTP *config.HTTPParams // non-nil for type http/https
|
HTTP *config.HTTPParams // non-nil for type http/https
|
||||||
TCP *config.TCPParams // non-nil for type tcp
|
TCP *config.TCPParams // non-nil for type tcp
|
||||||
|
|||||||
Reference in New Issue
Block a user