Skip to content

Conversation

dmitrykuzmin
Copy link
Contributor

@dmitrykuzmin dmitrykuzmin commented Aug 28, 2020

This PR partially addresses SpineEventEngine/web#6.

Currently, the Ack received from a command filter can contain either OK status, Error, or rejection Event.

While the first two cases are well-supported in the current implementation, the rejection field is not really expected to be populated.

Per vocal discussion, it was decided that receiving a rejection in a command filter is actually a valid use-case, and thus this PR tweaks the core to support such a case. The system context will post the corresponding system events when the command is rejected this way, and the provided rejection event will be posted to the EventBus.

Other changes

  • BusFilter interface is expanded with shortcut methods for the convenient Ack creation.
  • The command and event filters are included in the bounded context testingCopy() and can thus be specified on BlackBoxContext creation.
  • The AbstractCommandHandler will post the corresponding events when its handler method invocation leads to a rejection.

The library version advances to 1.5.27.

...to avoid the name clash with `io.spine.core.Acks`.
Also, delete a redundant test class.
@dmitrykuzmin dmitrykuzmin self-assigned this Aug 28, 2020
@codecov
Copy link

codecov bot commented Aug 28, 2020

Codecov Report

Merging #1295 into master will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             master    #1295      +/-   ##
============================================
- Coverage     91.05%   91.05%   -0.01%     
- Complexity     4714     4732      +18     
============================================
  Files           606      608       +2     
  Lines         15009    15063      +54     
  Branches        853      854       +1     
============================================
+ Hits          13666    13715      +49     
- Misses         1075     1081       +6     
+ Partials        268      267       -1     

@dmitrykuzmin dmitrykuzmin requested a review from armiol August 28, 2020 12:09
@dmitrykuzmin
Copy link
Contributor Author

@armiol PTAL.

Copy link
Contributor

@armiol armiol left a comment

Choose a reason for hiding this comment

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

@dmitrykuzmin LGTM in general. Please see my comments.

*/
@Internal
public final class Buses {
public final class AckFactory {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would call that Acks.

* {@linkplain Ack posting result} with either status otherwise
*/
Optional<Ack> accept(E envelope);
Optional<Ack> doFilter(E envelope);
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 why rename that.

The idea of having a method like doFilter() is to avoid the clash with filter() in the public API. We don't have filter() here.


@Override
public void onError(Throwable t) {
// NO-OP.
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we rethrow it?


@Override
public void onError(Throwable t) {
// NO-OP.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above. Shouldn't we rethrow the exception?

* An observer which processes the {@linkplain io.spine.base.ThrowableMessage rejections}
* thrown by the bus {@linkplain BusFilter filters}.
*
* <p>Is NO-OP at bus creation. Once an {@link EventBus} is
Copy link
Contributor

Choose a reason for hiding this comment

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

When the bus is first created, this observer does nothing. Once an {@link EventBus} is ...

@dmitrykuzmin dmitrykuzmin requested a review from armiol August 28, 2020 16:27
@dmitrykuzmin
Copy link
Contributor Author

@armiol PTAL again.

@dmitrykuzmin dmitrykuzmin merged commit 56204a2 into master Sep 1, 2020
@dmitrykuzmin dmitrykuzmin deleted the improve-command-filter-rejections-support branch September 1, 2020 10:47
This was referenced Sep 8, 2020
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