-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Expose WriteRequest.RefreshPolicy string representation #23106
Conversation
This commit changes the RefreshPolicy enum so that string representation are exposed. This will help the high level rest client to simply use refreshPolicy.getValue() to get the corresponding parameter value of a given refresh policy.
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.
left a couple of comments
@@ -65,45 +65,70 @@ default R setRefreshPolicy(String refreshPolicy) { | |||
/** | |||
* Don't refresh after this request. The default. | |||
*/ | |||
NONE, | |||
NONE((byte) 0, Boolean.FALSE.toString()), |
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.
nit: I am wondering if using "true" and "false" would be more readable, simply because I always forget if it's lowercase or uppercase.
WAIT_UNTIL; | ||
WAIT_UNTIL((byte) 2, "wait_for"); | ||
|
||
private final byte id; |
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.
can we remove the id member and stick with the enum ordinal like we were doing before?
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.
Yes we can :(
return policy; | ||
} | ||
} | ||
throw new IllegalArgumentException("No cluster block level matching [" + id + "]"); |
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.
is this a cluster block level?
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.
It's a wonderful copy paste
Thanks @javanna, I updated the code. |
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeByte(getId()); | ||
} | ||
out.writeByte((byte) ordinal()); } |
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.
Nit: }
is in a funny place.
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.
LGTM besides nik's comment
This commit changes the RefreshPolicy enum so that string representation are exposed. This will help the high level rest client to simply use refreshPolicy.getValue() to get the corresponding parameter value of a given refresh policy.
This commit changes the
RefreshPolicy
enum so that string representation are exposed. This will help the high level rest client to simply userefreshPolicy.getValue()
to get the corresponding parameter value of a given refresh policy.