Well.. that escalated quickly.

Completely forgot that Traefik uses outdated Yaegi and requires compatibility with 1.20 ( pre-generic Go code ).
This commit is contained in:
2025-06-20 19:23:50 +01:00
parent 70443f0855
commit 667b4213fe
24 changed files with 439 additions and 374 deletions
+11 -6
View File
@@ -4,7 +4,6 @@ import (
"context"
"errors"
"net"
"slices"
"testing"
"time"
)
@@ -208,7 +207,7 @@ func TestGracefulDegradation(t *testing.T) {
}()
t.Run("Register fallback and health check", func(t *testing.T) {
gd.RegisterFallback("test-service", func() (any, error) {
gd.RegisterFallback("test-service", func() (interface{}, error) {
return "fallback-result", nil
})
@@ -223,12 +222,12 @@ func TestGracefulDegradation(t *testing.T) {
})
t.Run("Execute with fallback on failure", func(t *testing.T) {
gd.RegisterFallback("failing-service", func() (any, error) {
gd.RegisterFallback("failing-service", func() (interface{}, error) {
return "fallback-result", nil
})
// First call should fail and mark service as degraded
result, err := gd.ExecuteWithFallback("failing-service", func() (any, error) {
result, err := gd.ExecuteWithFallback("failing-service", func() (interface{}, error) {
return nil, errors.New("service failure")
})
if err != nil {
@@ -245,7 +244,7 @@ func TestGracefulDegradation(t *testing.T) {
})
t.Run("No fallback available", func(t *testing.T) {
_, err := gd.ExecuteWithFallback("no-fallback-service", func() (any, error) {
_, err := gd.ExecuteWithFallback("no-fallback-service", func() (interface{}, error) {
return nil, errors.New("service failure")
})
@@ -256,7 +255,13 @@ func TestGracefulDegradation(t *testing.T) {
t.Run("Get degraded services", func(t *testing.T) {
degraded := gd.GetDegradedServices()
found := slices.Contains(degraded, "failing-service")
found := false
for _, s := range degraded {
if s == "failing-service" {
found = true
break
}
}
if !found {
t.Error("Expected failing-service to be in degraded list")
}