All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.scalecube.cluster.transport.api.MessageCodec Maven / Gradle / Ivy

The newest version!
package io.scalecube.cluster.transport.api;

import java.io.InputStream;
import java.io.OutputStream;
import java.util.ServiceLoader;
import java.util.stream.StreamSupport;

/** Contains methods for message serializing/deserializing logic. */
public interface MessageCodec {

  MessageCodec INSTANCE =
      StreamSupport.stream(ServiceLoader.load(MessageCodec.class).spliterator(), false)
          .findFirst()
          .orElseGet(JdkMessageCodec::new);

  /**
   * Deserializes message from given input stream.
   *
   * @param stream input stream
   * @return message from the input stream
   */
  Message deserialize(InputStream stream) throws Exception;

  /**
   * Serializes given message into given output stream.
   *
   * @param message message
   * @param stream output stream
   */
  void serialize(Message message, OutputStream stream) throws Exception;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy