1
0
mirror of https://github.com/redis/go-redis.git synced 2025-12-18 23:34:11 +03:00

fix(retry): Add retry mechanism for NOREPLICAS error (#3647)

This commit is contained in:
ofekshenawa
2025-12-10 18:14:05 +02:00
committed by GitHub
parent e4965ea90b
commit 4edf494293
5 changed files with 78 additions and 12 deletions

View File

@@ -9,12 +9,12 @@ import (
// TestTypedRedisErrors tests that typed Redis errors are created correctly
func TestTypedRedisErrors(t *testing.T) {
tests := []struct {
name string
errorMsg string
expectedType interface{}
expectedMsg string
checkFunc func(error) bool
extractAddr func(error) string
name string
errorMsg string
expectedType interface{}
expectedMsg string
checkFunc func(error) bool
extractAddr func(error) string
}{
{
name: "LOADING error",
@@ -132,6 +132,13 @@ func TestTypedRedisErrors(t *testing.T) {
expectedMsg: "OOM command not allowed when used memory > 'maxmemory'",
checkFunc: IsOOMError,
},
{
name: "NOREPLICAS error",
errorMsg: "NOREPLICAS Not enough good replicas to write",
expectedType: &NoReplicasError{},
expectedMsg: "NOREPLICAS Not enough good replicas to write",
checkFunc: IsNoReplicasError,
},
}
for _, tt := range tests {
@@ -389,4 +396,3 @@ func TestBackwardCompatibility(t *testing.T) {
})
}
}