feat(chord): ErrorCallback to handle Group failures #605
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A chord is a Group and a task that executes when the Group is done with the results of the group.
If a task fails in that group - nothing gets called at the end of the group execution.
Proposal:
NewChordWithError
which would make aChord(Group, SuccessTask, FailureTask)
using the following logic:The FailureTask would take an aggregate of errors of all the failed tasks e.g.
func FailureTask(errs []string) error
Any successful completions of the tasks in the group would be 'dropped'
Changes in this PR
tasks.NewChordWithError()
function that takes an additionalSignature
tasks.NewChord
maintains backwards compatiblityresults.AsyncChordResult
behavior modified to fetch ErrorCallback results if one of the tasks failsworker.go
modifications for processingErrorChord
processChord
Server
andWorker
Note: Unit tests made this a larger change as they required making interfaces out of Server and Worker and injecting those into processing functions. I'd love to take this effort further - but I wanted to keep this change as small as possible. It's already 16 files so I somewhat failed at that.
Let me know if you have thoughts on the utility of the change, etc