Skip to content
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

Streaming query support #112

Merged
merged 21 commits into from Mar 24, 2022
Merged

Streaming query support #112

merged 21 commits into from Mar 24, 2022

Conversation

schananas
Copy link
Contributor

Adds few adjustemnts and fixes for better streaming query support

@CLAassistant
Copy link

CLAassistant commented Nov 9, 2021

CLA assistant check
All committers have signed the CLA.

@schananas
Copy link
Contributor Author

Integration tests to be done

@schananas schananas marked this pull request as draft November 9, 2021 10:00

@Override
public void request(long requested) {
delegates.parallelStream()
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't this cause a "request 1" to lead to more than 1 message being sent? Is this acceptable or should we buffer the responses and deplete the buffer before asking more from upstream?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, you are right! We could also do a round-robin without the buffer - no necessary invocations. What do you think?

result.complete();
}

private void flowControlQuery(QueryProviderInbound flowControl, ReplyChannel<QueryProviderOutbound> result) {
Copy link
Contributor

Choose a reason for hiding this comment

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

to avoid confusion, I suggest renaming. For example: handleFlowControlRequest

@@ -191,6 +193,18 @@ public void complete() {
result.complete();
}

private void completeStreamingQuery(QueryProviderInbound complete, ReplyChannel<QueryProviderOutbound> result) {
Copy link
Contributor

Choose a reason for hiding this comment

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

In line with comment below suggestion: handleCancelRequest

MultiFlowControl multiFlowControl = new MultiFlowControl();
Runnable removeQuery = () -> queriesInProgress.remove(query.getMessageIdentifier());
QueryInProgress queryInProgress = new QueryInProgress(removeQuery, multiFlowControl);
queriesInProgress.putIfAbsent(query.getMessageIdentifier(), queryInProgress);
Copy link
Contributor

Choose a reason for hiding this comment

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

The use of putIfAbsent suggests that the given identifier may already exist. In that case, wouldn't we want to use the already existing QueryInProgess instance? Of maybe reject the request altogether?

Copy link
Contributor

Choose a reason for hiding this comment

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

Semantically, I think we want to reject the request. If there is already the same query in progress, responses sent are valid, and responses to be sent are going to be valid. If you want a new result stream, issue a new query. If, however, receiving the same query twice is a result of a retry, rejecting it is also fine.

return closeHandler;
}

public void complete() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest: rename to cancel()

Instead of completing normally, perhaps complete with a QueryCancelledException instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure whether we want to complete exceptionally here. Having a receiver cancelling the stream doesn't seem like an exceptional case but rather a regular one.

@sonarcloud
Copy link

sonarcloud bot commented Dec 13, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

78.5% 78.5% Coverage
0.0% 0.0% Duplication

@m1l4n54v1c m1l4n54v1c self-assigned this Feb 22, 2022
@m1l4n54v1c m1l4n54v1c marked this pull request as ready for review February 22, 2022 10:49
Added test for exception throwing FlowControl.
Copy link
Contributor

@smcvb smcvb left a comment

Choose a reason for hiding this comment

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

Implementation wise I approve this PR, as I assume is known through the virtual reviews we've done. I've got plenty of JavaDoc suggestions as always, however.

@smcvb
Copy link
Contributor

smcvb commented Mar 11, 2022

Also, don't forget to take a look at Sonar. It marks one bug and four code smells.

Copy link
Contributor

@smcvb smcvb left a comment

Choose a reason for hiding this comment

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

My concerns have been addressed, hence approving.

@m1l4n54v1c m1l4n54v1c merged commit 731f853 into master Mar 24, 2022
@m1l4n54v1c m1l4n54v1c deleted the streaming-query branch March 24, 2022 14:44
@sonarcloud
Copy link

sonarcloud bot commented Mar 24, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants