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

in.ashwanthkumar.suuchi.router.Marshallers.scala Maven / Gradle / Ivy

There is a newer version: 0.3.5
Show newest version
package in.ashwanthkumar.suuchi.router

import in.ashwanthkumar.suuchi.membership.MemberAddress
import io.grpc.Metadata.AsciiMarshaller

/**
 * Send a string value using AsciiMarshaller
 */
case object StringMarshaller extends AsciiMarshaller[String] {
  override def toAsciiString(value: String): String = value
  override def parseAsciiString(serialized: String): String = serialized
}

/**
 * Converts a collection of [[MemberAddress]] to it's external form separated by `|`
 */
case object MemberAddressMarshaller extends AsciiMarshaller[List[MemberAddress]] {
  override def parseAsciiString(serialized: String): List[MemberAddress] = serialized.split('|').map(MemberAddress.apply).toList
  override def toAsciiString(value: List[MemberAddress]): String = value.map(_.toExternalForm).mkString("|")
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy