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

Introduce ResultStreamPublisher to interact with a ResultStream through a Publisher. #142

Merged

Conversation

saratry
Copy link
Contributor

@saratry saratry commented Jan 20, 2022

No description provided.

Copy link
Contributor

@abuijze abuijze left a comment

Choose a reason for hiding this comment

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

A few recommendations to simplify things.

pom.xml Show resolved Hide resolved
ResultStream<Message> resultStream) {
this.subscriber = subscriber;
this.resultStream = resultStream;
this.resultStream.onAvailable(this::signal);
Copy link
Contributor

@abuijze abuijze Jan 21, 2022

Choose a reason for hiding this comment

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

Having callbacks triggered to an object that hasn't been constructed completely yet is generally not recommended.
In a comparable situation, we have chosen to register this callback in the request method, with the following pseudo-code:

  if (requested.getAndUpdate(prev -> prev + n) == 0) {
      this.resultStream.onAvailable(this::signal);
  } 
  signal();
}

The resultstream will only remember the last registered callback, so there is only very little overhead in this operation.

Copy link
Contributor Author

@saratry saratry Jan 21, 2022

Choose a reason for hiding this comment

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

what about moving that line into afterSubscribe method?

private void afterSubscribe() {
    this.resultStream.onAvailable(this::signal);
    signal();
}

In this way, it is executed only once.

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.

A bunch of minor pointers to chat about.
And, don't forget the code smell SonarCloud marked.
It's about the generic name you've used, so I would anticipate it to be resolved after processing the comments anyhow.

@saratry saratry requested review from abuijze and smcvb January 21, 2022 14:55
@sonarcloud
Copy link

sonarcloud bot commented Jan 21, 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

78.4% 78.4% Coverage
0.0% 0.0% Duplication

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.

@saratry saratry merged commit 58b8f7d into feature/adminApi/getEventProcessors Jan 26, 2022
@saratry saratry deleted the feature/result-stream-adapter branch January 26, 2022 13:49
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

4 participants