-
Notifications
You must be signed in to change notification settings - Fork 12
Improve support of rejections thrown from the CommandBus
filters
#1295
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
Improve support of rejections thrown from the CommandBus
filters
#1295
Conversation
...to avoid the name clash with `io.spine.core.Acks`.
Also, delete a redundant test class.
Codecov Report
@@ 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 |
@armiol PTAL. |
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.
@dmitrykuzmin LGTM in general. Please see my comments.
*/ | ||
@Internal | ||
public final class Buses { | ||
public final class AckFactory { |
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.
I would call that Acks
.
* {@linkplain Ack posting result} with either status otherwise | ||
*/ | ||
Optional<Ack> accept(E envelope); | ||
Optional<Ack> doFilter(E envelope); |
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.
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. |
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.
Shouldn't we rethrow it?
|
||
@Override | ||
public void onError(Throwable t) { | ||
// NO-OP. |
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.
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 |
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.
When the bus is first created, this observer does nothing. Once an {@link EventBus} is ...
@armiol PTAL again. |
This PR partially addresses SpineEventEngine/web#6.
Currently, the
Ack
received from a command filter can contain eitherOK
status,Error
, or rejectionEvent
.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 theEventBus
.Other changes
BusFilter
interface is expanded with shortcut methods for the convenientAck
creation.testingCopy()
and can thus be specified onBlackBoxContext
creation.AbstractCommandHandler
will post the corresponding events when its handler method invocation leads to a rejection.The library version advances to
1.5.27
.