-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Introduce a common base response class to all single doc write ops #15334
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
Conversation
@ywelsch can you please take a look? |
/** | ||
* A base class for the response of a write operation that involves a single doc | ||
*/ | ||
public abstract class DocWriteResponse extends ReplicationResponse implements ToXContent { |
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.
call this DocOperationResponse (as it includes deletes)?
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 think deleted is a write operation? DocOperationResponse as a name does cover Get, which isn't part of this game...
Minor comments, o.w. LGTM |
IndexResponse, DeleteResponse and UpdateResponse share some logic. This can be unified to a single DocWriteResponse base class. On top, some replication actions are now not about write operations anymore. This commit renames ActionWriteResponse to ReplicationResponse Last some toXContent is moved from the Rest layer to the actual response classes, for more code re-sharing. This is ported over from the `feature/seq_no` branch to make maintaining that branch simpler
7afde9a
to
952c38f
Compare
@ywelsch @martijnvg I addressed all your feedback and rebased on master (there was a big change to replication action there). Can you take another look? |
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.field(Fields.FOUND, isFound()); | ||
super.toXContent(builder, params); |
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.
switch these 2 lines so that id, version etc. appear first?
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.
This how it used to be (found first), and I tend to agree - the found flag is the mode important one. Might be inconsistent but it's not my goal to change this in this PR (requires research on the other endpoints as well)
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.
ok, just noticed this in comparison to IndexResponse.
More lines removed than added -> I like this. |
Good stuff. LGTM |
@ywelsch pushed another round with your suggestions. |
LGTM |
IndexResponse, DeleteResponse and UpdateResponse share some logic. This can be unified to a single DocWriteResponse base class. On top, some replication actions are now not about write operations anymore. This commit renames ActionWriteResponse to ReplicationResponse
Last some toXContent is moved from the Rest layer to the actual response classes, for more code re-sharing.
This is ported over from the
feature/seq_no
branch to make maintaining that branch simpler