{"id":"cfe4ad84a56f67a9","repo":"go-redis/redis","slug":"to-route-commands-by-latency-use-newfailoverclust","errorCode":null,"errorMessage":"to route commands by latency, use NewFailoverClusterClient","messagePattern":"to route commands by latency, use NewFailoverClusterClient","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sentinel.go","lineNumber":540,"sourceCode":"\t// any parameters left?\n\tif r := q.remaining(); len(r) > 0 {\n\t\treturn nil, fmt.Errorf(\"redis: unexpected option: %s\", strings.Join(r, \", \"))\n\t}\n\n\treturn o, nil\n}\n\n// NewFailoverClient returns a Redis client that uses Redis Sentinel\n// for automatic failover. It's safe for concurrent use by multiple\n// goroutines.\n// Passing nil FailoverOptions will cause a panic.\nfunc NewFailoverClient(failoverOpt *FailoverOptions) *Client {\n\tif failoverOpt == nil {\n\t\tpanic(\"redis: NewFailoverClient nil options\")\n\t}\n\n\tif failoverOpt.RouteByLatency {\n\t\tpanic(\"to route commands by latency, use NewFailoverClusterClient\")\n\t}\n\tif failoverOpt.RouteRandomly {\n\t\tpanic(\"to route commands randomly, use NewFailoverClusterClient\")\n\t}\n\n\tsentinelAddrs := make([]string, len(failoverOpt.SentinelAddrs))\n\tcopy(sentinelAddrs, failoverOpt.SentinelAddrs)\n\n\trand.Shuffle(len(sentinelAddrs), func(i, j int) {\n\t\tsentinelAddrs[i], sentinelAddrs[j] = sentinelAddrs[j], sentinelAddrs[i]\n\t})\n\n\tfailover := &sentinelFailover{\n\t\topt:           failoverOpt,\n\t\tsentinelAddrs: sentinelAddrs,\n\t}\n\n\topt := failoverOpt.clientOptions()","sourceCodeStart":522,"sourceCodeEnd":558,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/sentinel.go#L522-L558","documentation":"Error \"to route commands by latency, use NewFailoverClusterClient\" thrown in go-redis/redis.","triggerScenarios":"Thrown at sentinel.go:540 when the library encounters an invalid state.","commonSituations":"Match routing options to the client constructor that supports them.","solutions":["Use NewFailoverClusterClient when RouteByLatency routing is required","Disable RouteByLatency for the simple failover client"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}