Skip to content

Bolt V3 #517

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

Merged
merged 6 commits into from
Jul 27, 2018
Merged

Bolt V3 #517

merged 6 commits into from
Jul 27, 2018

Conversation

lutovich
Copy link
Contributor

Added new message types and logic for handling them. New metadata like tx_timeout and tx_metadata are not used yet.

Renamed NettyConnection to DirectConnection and Bookmark to Bookmarks.

@lutovich lutovich requested a review from zhenlineo July 26, 2018 10:41
lutovich added 5 commits July 26, 2018 13:18
Added new messages and ability to write them into a network channel.
Introduced Bolt V3 abstraction that uses new messages to execute
execute queries, begin/commit/rollback transactions.

Code does not yet use new metadata.
This is a better name because class holds a collection of bookmarks,
not just a single one.
It always used V1 message format before.
Metadata keys are different in previous versions of the protocol.
This commit makes it possible for keys to be defined by each Bolt
protocol implementation.

Also fixed couple unit tests and added license headers.
@@ -66,10 +67,11 @@
private CompletableFuture<Record> recordFuture;
private CompletableFuture<Throwable> failureFuture;

public PullAllResponseHandler( Statement statement, RunResponseHandler runResponseHandler, Connection connection )
public PullAllResponseHandler( Statement statement, RunResponseHandler runResponseHandler, String resultConsumedAfterMetadataKey, Connection connection )
Copy link
Contributor

@zhenlineo zhenlineo Jul 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see why you have this key here,
but how about override this class and then have two implementation of extractResultSummary method? Versioning response handler sound a reasonable thing.

public ResultSummary extractResultSummary( Map<String,Value> metadata ) {
  long resultAvailableAfter = runResponseHandler.resultAvailableAfter();
  return MetadataUtil.extractSummary( statement, connection, resultAvailableAfter, metadata, T_LAST_KEY );
  // or RESULT_COMSUMED_AFTER_KEY for v1 and v2
}

Similarly for RunResponseHandler, we can override onSuccess or onMeta?

Copy link
Contributor Author

@lutovich lutovich Jul 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I'll give this a try. Might especially be valuable if we add another response metadata field

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the metadata extraction utility versioned instead of passing string keys around. Creating classes felt a little to much - 3 new classes would need to be created just to override 2 string keys


final Map<String,Value> metadata;

TransactionStartingMessage( Bookmarks bookmarks, Duration txTimeout, Map<String,Value> txMetadata )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha, smart interface to take all transaction related metadata

ChannelPromise channelPromise = channel.newPromise();
HelloResponseHandler handler = new HelloResponseHandler( channelPromise );

assertThrows( IllegalArgumentException.class, () -> handler.onSuccess( singletonMap( "server", value( "WrongServerVersion" ) ) ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it still required to have the server version parsed rather than simply record it as a simple message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Server version should not be needed for version comparisons in Bolt V3. It is just easier to still keep it as ServerVersion object for older protocol versions

Instead of passing string metadata keys around. This is needed because
some metadata keys have changed in Bolt V3 compared to Bolt V1.
@zhenlineo zhenlineo merged commit 841f92b into neo4j:1.7 Jul 27, 2018
@lutovich lutovich deleted the 1.7-bolt-v3 branch July 27, 2018 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants