glaforge/gaelyk — pull request #126 by codeconsole (2012-03-13 20:09:18+00:00)
Title: Serving url retry

getServingUrl is highly unreliable at times, this makes it a lot better.

Here is example code I use:

image.url = blobKey.getServingUrl(retry: 2, onRetry: { ex, i ->
log.info("${ex.toString()} ${i} ${blobKey.keyString}".toString())
Thread.sleep(2000)
String status = 'stat.upload.'
if (ex instanceof ApiDeadlineExceededException) {
status += 'apiDeadline'
} else if (ex instanceof IllegalArgumentException) {
status += 'illegalArgument'
} else if (ex instanceof ImagesServiceFailureException) {
status += 'imagesServiceFailure'
}
if (i) { status += (i + 1) }
categoryService.incrementStat(status)
true
}, onFail: {})

Note: I have passed onFail an empty closure. If you do not specify an onFail closure, the underlying exception will still be thrown.