anton-vinogradov commented on code in PR #13095:
URL: https://github.com/apache/ignite/pull/13095#discussion_r3598569576


##########
modules/nio/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java:
##########
@@ -38,4 +38,36 @@ public interface MessageSerializer<M extends Message> {
      * @return Whether message was fully read.
      */
     public boolean readFrom(M msg, MessageReader reader);
+
+    /**
+     * Writes the message using the serializer resolved from the factory.
+     *
+     * @param factory Message factory.
+     * @param msg Message instance.
+     * @param writer Writer.
+     * @param <M> Message type.
+     * @return Whether message was fully written.
+     */
+    static <M extends Message> boolean writeTo(MessageFactory factory, M msg, 
MessageWriter writer) {
+        return resolve(factory, msg).writeTo(msg, writer);
+    }
+
+    /**
+     * Reads the message using the serializer resolved from the factory.
+     *
+     * @param factory Message factory.
+     * @param msg Message instance.
+     * @param reader Reader.
+     * @param <M> Message type.
+     * @return Whether message was fully read.
+     */
+    static <M extends Message> boolean readFrom(MessageFactory factory, M msg, 
MessageReader reader) {
+        return resolve(factory, msg).readFrom(msg, reader);
+    }
+
+    /** @return the serializer registered for {@code msg}'s direct type. */
+    @SuppressWarnings("unchecked")
+    private static <M extends Message> MessageSerializer<M> 
resolve(MessageFactory factory, M msg) {

Review Comment:
   Done — revisited after the marshalling refactor made the family 
inconsistent: the statics (`writeTo`/`readFrom` and the private `resolve`) 
moved out of the interface into a new `MessageSerialization` facade (next to 
`GridNioServer`), the exact counterpart of `MessageMarshalling` on the 
serialization side. `MessageSerializer` is now a pure per-type contract with 
the two instance methods.



##########
modules/nio/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageSerializer.java:
##########
@@ -38,4 +38,36 @@ public interface MessageSerializer<M extends Message> {
      * @return Whether message was fully read.
      */
     public boolean readFrom(M msg, MessageReader reader);
+
+    /**
+     * Writes the message using the serializer resolved from the factory.
+     *
+     * @param factory Message factory.
+     * @param msg Message instance.
+     * @param writer Writer.
+     * @param <M> Message type.
+     * @return Whether message was fully written.
+     */
+    static <M extends Message> boolean writeTo(MessageFactory factory, M msg, 
MessageWriter writer) {

Review Comment:
   Done — the `SerializationUtil/Helper` you suggested now exists as 
`MessageSerialization` (mirroring `MessageMarshalling`): the interface keeps 
only the instance contract, the resolve-and-dispatch statics live in the 
facade, and the ArchUnit rule enforces that everyone else calls the facade.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to