-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
[refactor] Migrate Usages of Streamable to Writeable #34389
Comments
Pinging @elastic/es-core-infra |
I think we need a migration plan for Response objects. As far as I can tell we are missing the framework for an
I do wonder if this is the right time to make these objects immutable; if there is a builder we can add mutable fields in the builder and build the immutable request object upon calling |
Are you saying you'd like to make these objects immutable as we go? I'm on board with that, though superclasses make that hard. But it is still a nice goal. Maybe not for (some) requests though, because we still use them in the high level rest client and transport client. Once we've stopped using them in the high level rest client I think we should make them immutable. |
I think we need a refactoring meta-issue for this effort too. |
Yes I would like to do it as much as possible and understand that in some places it might not be worth trying to do as we go like if there are superclasses that conflict with making things immutable. It has always bothered me that request/responses could be mutable. |
This commit replaces usage of Streamable with Writeable within the RoleDescriptor class (and inner classes). Relates: elastic#34389
This commit replaces usage of Streamable with Writeable within the RoleDescriptor class (and inner classes). Relates: #34389
In order to remove Streamable from the codebase, Response objects need to be read using the Writeable.Reader interface which this change enables. This change enables the use of Writeable.Reader by adding the `Action#getResponseReader` method. The default implementation simply uses the existing `newResponse` method and the readFrom method. As responses are migrated to the Writeable.Reader interface, Action classes can be updated to throw an UnsupportedOperationException when `newResponse` is called and override the `getResponseReader` method. Relates elastic#34389
This commit replaces usage of Streamable with Writeable within the RoleDescriptor class (and inner classes). Relates: #34389
In order to remove Streamable from the codebase, Response objects need to be read using the Writeable.Reader interface which this change enables. This change enables the use of Writeable.Reader by adding the `Action#getResponseReader` method. The default implementation simply uses the existing `newResponse` method and the readFrom method. As responses are migrated to the Writeable.Reader interface, Action classes can be updated to throw an UnsupportedOperationException when `newResponse` is called and override the `getResponseReader` method. Relates #34389
In order to remove Streamable from the codebase, Response objects need to be read using the Writeable.Reader interface which this change enables. This change enables the use of Writeable.Reader by adding the `Action#getResponseReader` method. The default implementation simply uses the existing `newResponse` method and the readFrom method. As responses are migrated to the Writeable.Reader interface, Action classes can be updated to throw an UnsupportedOperationException when `newResponse` is called and override the `getResponseReader` method. Relates #34389
With the incorporation of #34655, Response objects can now use the Lines 45 to 62 in 052dfa5
The Lines 64 to 67 in 052dfa5
The action class, Lines 39 to 42 in 052dfa5
Finally, the Lines 34 to 37 in 052dfa5
|
This commit replaces usage of Streamable with Writeable within the RoleDescriptor class (and inner classes). Relates: #34389
In order to remove Streamable from the codebase, Response objects need to be read using the Writeable.Reader interface which this change enables. This change enables the use of Writeable.Reader by adding the `Action#getResponseReader` method. The default implementation simply uses the existing `newResponse` method and the readFrom method. As responses are migrated to the Writeable.Reader interface, Action classes can be updated to throw an UnsupportedOperationException when `newResponse` is called and override the `getResponseReader` method. Relates #34389
This commit replaces usages of Streamable with Writeable for the BaseTasksRequest / TransportTasksAction classes and subclasses of these classes. Relates to elastic#34389
This commit replaces usages of Streamable with Writeable for the BaseTasksResponse / TransportTasksAction classes and subclasses of these classes. Note that where possible response fields were made final. Relates to elastic#34389
Reason for migration
Implementers of the Streamable interface almost always declare a no arg constructor that is exclusively used for creating "empty" objects on which you then call
#readFrom(StreamInput)
. Because#readFrom(StreamInput)
isn't part of the constructor the fields on implementers cannot be final. It is these reasons that this interface has fallen out of favor compared to WriteableMigration plan
Some steps have already begun:
Next Steps:
Example Migration
Let's assume there is a concrete class that does not have any constraints via inheritance, and can simply be migrated from Streamable to Writeable, it is best to do the following:
readFrom
method override with a method that throws an exception. This ensures that the Streamable interface for this class is never actually used.readFrom
implementation into a Writeable.Reader-compatible constructorfinal
Classes (757 as of opening this issue) that implement Streamble
Class Hierarchy
The text was updated successfully, but these errors were encountered: