-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvements for StatementResultCursor API #405
Merged
lutovich
merged 8 commits into
neo4j:1.5-async
from
lutovich:1.5-async-result-cursor-api
Sep 22, 2017
Merged
Improvements for StatementResultCursor API #405
lutovich
merged 8 commits into
neo4j:1.5-async
from
lutovich:1.5-async-result-cursor-api
Sep 22, 2017
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is a test-only implementation of `RetryLogic` interface that retries up to a specified amount of times. It previously had a separate implementation which was basically a simplified version of `ExponentialBackoffRetryLogic`. It is problematic for following `retryAsync` functionality because implementation will not be that simple. This commit makes `FixedRetryLogic` extend `ExponentialBackoffRetryLogic` and override just a single method. So that they can share complicated retrying code.
This commit makes retry logic able to retry work that executes async operations and return a `Future`. It's a first step towards supporting async transaction functions. Also renamed future combinator methods to better represent their intent.
Via `Session#readTransactionAsync()` and `#writeTransactionAsync()`. Both accept a single parameter - async function that takes a transaction and returns a `Response`. When function returns a failed response or throws exception it will be retried. Retries only happen on non-fatal & transient errors. API is not fully complete yet - there is no way to create a `Result` object so it'll be inconvenient to use. Helpers to create some sort of "settable" response will come in subsequent commits.
Given work might fail by throwing exception or by returning a failed future. This commit makes retries gracefully handle exceptions. Previously retrying code would only log an exception and hang.
Transaction should be marked as failed when queries fail. It was previously only marked when PULL_ALL failed. This commit makes RUN handler notify transaction on failure.
Commit replaces `Response<Boolean> #fetchAsync()` + `Record #current()` in `StatementResultCursor` with single `Response<Record> #nextAsync()`. This simplifies API and makes it more convenient to consume records via future chaining and callbacks. `Response` is already a container for record, it can't contain anything else. So it makes sense to return `null` as an end of records stream marker and not use separate method for this. Also added `#peekAsync()` method.
Method allows processing of every incoming record in an async fashion. It returns a future which signals about processing completion. It can either be failed or completed with `null`.
Method allows async retrieval of all records as list.
ali-ince
approved these changes
Sep 22, 2017
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
A few commits:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Based on #404.
Main changes:
#fetchAsync()
+#current()
with single#nextAsync()
to simplify handling of futures#forEachAsync()
#listAsync()