appengine
appengine copied to clipboard
datastore: Specific timeout errors
In both Java and Python it is possible to handle datastore timeout errors in code, according to this text: https://cloud.google.com/appengine/articles/handling_datastore_errors
In Go however, a error from the internal packages are returned (Call error 11: Deadline exceeded (timeout) ) where there is no mention of datastore.
It would be nice if there was a specific error, like there is with datastore's concurrent transaction error ErrConcurrentTransaction.
Apparently you can check if an error is a timeout error: https://cloud.google.com/appengine/docs/standard/go/reference#IsTimeoutError
import "google.golang.org/appengine"
...
appengine.IsTimeoutError(err)
Unfortunately that doesn't appear to work for me. Maybe you've got more luck?
@ldej appengine.IsTimeoutError only works for some timeouts. If you check the code, it checks for context.DeadlineExeeded-error and errors that implement IsTimeout() bool. So it misses i.e url.Error that instead implement Timeout() bool
So we implemeted our own IsTimeoutError(error) bool that checks for all of those