Skip to content

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

Closed
wants to merge 5 commits into from

Conversation

bleskes
Copy link
Contributor

@bleskes bleskes commented Dec 9, 2015

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

@bleskes
Copy link
Contributor Author

bleskes commented Dec 9, 2015

@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 {
Copy link
Contributor

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)?

Copy link
Contributor Author

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...

@ywelsch
Copy link
Contributor

ywelsch commented Dec 9, 2015

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
@bleskes
Copy link
Contributor Author

bleskes commented Dec 10, 2015

@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);
Copy link
Contributor

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?

Copy link
Contributor Author

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)

Copy link
Contributor

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.

@ywelsch
Copy link
Contributor

ywelsch commented Dec 10, 2015

More lines removed than added -> I like this.
Left two suggestions, o.w. LGTM

@martijnvg
Copy link
Member

Good stuff. LGTM

@bleskes
Copy link
Contributor Author

bleskes commented Dec 10, 2015

@ywelsch pushed another round with your suggestions.

@ywelsch
Copy link
Contributor

ywelsch commented Dec 10, 2015

LGTM

@bleskes bleskes closed this in fafeb3a Dec 10, 2015
@bleskes bleskes deleted the doc_write_response branch December 10, 2015 14:17
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.

3 participants