Open orthros opened 5 years ago
Change https://golang.org/cl/151658 mentions this issue: maintner: add ability to define custom checks on sync errors
@bradfitz @dmitshur
if
Sync
is called, and any repository sync operation fails, the entire error group will exit ... a single temporary error in theSync
call will always abort all other routines in the group
I agree that behavior of Sync
(without loop) is suboptimal in that regard. I hope we can come up with a solution that is better than asking the user to provide a custom isTempErr
function.
How would you like Sync
to behave if one of the repos runs into an error? Should it retry temporary errors up to a fixed number of times, before giving up (and aborting all other repo goroutines)? Or should it collect errors it runs into, and report them at the end (without aborting other repo goroutines)? Or a mix of the two?
If we decide to make it possible for users to provide a custom isTempErr
, perhaps it'd be cleaner to make it an exported field on Corpus
rather than a new parameter.
Currently
isTempError
logs the error and vacuously returns trueThis is used in the
sync
function's error group members in conjunction withloop
to determine if the error returned from the various sourcesync
functions is a temporary error or not.This guarantees that if
SyncLoop
is called, the routines will loop forever (loop
is true andisTempErr
always returns true), but it also means that ifSync
is called, and any repository sync operation fails, the entire error group will exit. In acorpus
that is tracking hundreds of repositories with tens of thousands of issues, a single temporary error in theSync
call will always abort all other routines in the group.It would be useful to be able to provide criteria for what constitutes a temporary error or not.
I propose something similar to the following:
This would give the consumers of
corpus
the ability to determine what constitutes a temporary error, but default back to the old behaviour by passingnil
toSync
andSyncLoop