IsTemporaryKvError returns true if a kv operation has an error that is likely to be ephemeral. This represents situations where Couchbase Server is under load and would be expected to return a success or failure in a future call.
(err error)
| 252 | // IsTemporaryKvError returns true if a kv operation has an error that is likely to be ephemeral. This represents |
| 253 | // situations where Couchbase Server is under load and would be expected to return a success or failure in a future call. |
| 254 | func IsTemporaryKvError(err error) bool { |
| 255 | if err == nil { |
| 256 | return false |
| 257 | } |
| 258 | // define list of temporary errors |
| 259 | temporaryKVError := []error{ |
| 260 | ErrTimeout, // Sync Gateway client-side timeout |
| 261 | gocb.ErrTimeout, // SDK op timeout. Wrapped by gocb.ErrAmbiguousTimeout, gocb.ErrUnambiguousTimeout, |
| 262 | gocb.ErrOverload, // SDK client-side pipeline queue full, request was not submitted to server |
| 263 | gocb.ErrTemporaryFailure, // Couchbase Server returned temporary failure error |
| 264 | gocb.ErrCircuitBreakerOpen, // SDK client-side circuit breaker blocked request |
| 265 | } |
| 266 | |
| 267 | // iterate through to check incoming error is one of them |
| 268 | for _, tempKVErr := range temporaryKVError { |
| 269 | if errors.Is(err, tempKVErr) { |
| 270 | return true |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | return false |
| 275 | } |
| 276 | |
| 277 | func IsTimeoutError(err error) bool { |
| 278 | if err == nil { |