Source.run/1 error handling #180
Open
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 new attempt at adding error handling to the
Source.run/1call.This has been attempted twice before, #155 and #153. Both were (implicitly) closed due to me being dragged away for a very long time, sorry about that.
If the
Source.run/1function returns an error tuple, raises an error or takes longer thanDataloader.dataloader_timeout/1theSourceis removed from:sourcesfield and the key:errorwith thereasonas value is added.This causes a variety of issues down the line, among them the misleading/unhelpful error message:
This PR intends to preserve the source name key and replace the source implementation with
{:error, reason}instead of replacing the source key value pair with the error key value pair.There is no reasonable recovery in case of a failure. This is motivated by a two points:
retry the same batches with potential additional batches. If the issue causing a timeout is not
resolved between runs it will incur severe delays to full response.
between failures of future batch/key and the previous Source error without keeping track of
which batch was part of which run. Not distinguishing between different errors could be
very detrimental during debugging.
It works seamlessly for
Dataloader.get/4andDataloader.get_many/4as they will simply handle the error tuple as any other error tuple.It works fine for
pending_batches?as source that has returned an error does not have any pending batches, iefalseis a reasonable return value.It is a little icky with
Dataloader.put/5since it is currently no perceivable difference between calling it on an errored source and not. The error will not be triggered untilDataloader.get/4orDataloader.get_many/4is called.It is a little icky with
Dataloader.load/4andDataloader.load_many/4since it is currently no perceivable difference between calling it on an errored source and not. The error will not be triggered untilDataloader.get/4orDataloader.get_many/4is called.Additional changes
max_timeoutfeatureThoughts?