abstract class CirceAkkaSerializer[Ser <: AnyRef] extends SerializerWithStringManifest with CirceTraitCodec[Ser] with AkkaCodecs
An abstract class that is extended to create a custom serializer.
After creating your subclass, don't forget to add your serializer and base trait to application.conf (for more info
https://doc.akka.io/docs/akka/current/serialization.html)
Example subclass:
class CustomSerializer(actorSystem: ExtendedActorSystem) extends CirceAkkaSerializer[MySerializable](actorSystem) { implicit private val serializabilityCodec: Codec[MySerializable] = genericCodec override def identifier: Int = 41 override lazy val codecs = Seq( Register[SthCommand], Register(implicitly[ru.TypeTag[ModifiedCodec]], prepareEncoder, prepareDecoder), Register[GenericClass[MySerializable, MySerializable]]) override lazy val manifestMigrations = Seq("app.OldName" -> classOf[TopTraitMigration]) override lazy val packagePrefix = "app" }
- Ser
base trait that is used to mark serialization
- Alphabetic
- By Inheritance
- CirceAkkaSerializer
- AkkaCodecs
- CirceTraitCodec
- Codec
- Encoder
- Decoder
- Serializable
- SerializerWithStringManifest
- Serializer
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
CirceAkkaSerializer(system: ExtendedActorSystem)(implicit arg0: ClassTag[Ser])
- system
ExtendedActorSystem that is provided by Akka
Abstract Value Members
-
abstract
val
codecs: Seq[Registration[_ <: Ser]]
Sequence that must contain org.virtuslab.ash.circe.Registration for all direct subclasses of Ser.
Sequence that must contain org.virtuslab.ash.circe.Registration for all direct subclasses of Ser.
Each
Registrationis created using org.virtuslab.ash.circe.Registers org.virtuslab.ash.circe.Register#apply method.To check if all needed classes are registered, use Codec Registration Checker.
- Definition Classes
- CirceTraitCodec
- See also
org.virtuslab.ash.circe.Registerorg.virtuslab.ash.circe.Register#apply for more information about type derivation
-
abstract
def
identifier: Int
- Definition Classes
- SerializerWithStringManifest → Serializer
-
abstract
val
manifestMigrations: Seq[(String, Class[_])]
A sequence containing information used in type migration.
A sequence containing information used in type migration.
If you ever change the name of a class that is a direct descendant of
Serand is persisted in any way, you must append new pair to this field.- The first element of the pair is a String with the value of old FQCN.
- The second element of the pair is a Class that had its name changed
Example:
override lazy val manifestMigrations = Seq( "app.OldName" -> classOf[app.NewName] )
- Definition Classes
- CirceTraitCodec
-
abstract
val
packagePrefix: String
Package prefix of your project.
Package prefix of your project. Ensure that
Seris included in that package and as many classes that extend it.It should look something like
"org.group.project"It is used for some runtime checks that are executed at the end of constructor.
- Definition Classes
- CirceTraitCodec
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
implicit
def
actorRefCodec[T](implicit system: ActorSystem = serializationSystem): Codec[ActorRef[T]]
- Definition Classes
- AkkaCodecs
-
def
apply(a: Ser): Json
Encoder apply method - encodes given object of type Ser into Json
Encoder apply method - encodes given object of type Ser into Json
- Definition Classes
- CirceTraitCodec → Encoder
-
def
apply(c: HCursor): Result[Ser]
Decoder apply method - decodes from Json into an object of type Ser
Decoder apply method - decodes from Json into an object of type Ser
- Definition Classes
- CirceTraitCodec → Decoder
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
final
def
at(field: String): Decoder[Ser]
- Definition Classes
- Decoder
-
val
bufferSize: Int
- Attributes
- protected
-
lazy val
classTagEvidence: ClassTag[Ser]
- Definition Classes
- CirceAkkaSerializer → CirceTraitCodec
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native() @HotSpotIntrinsicCandidate()
-
val
codecsMap: Map[String, (Encoder[_ <: Ser], Decoder[_ <: Ser])]
- Attributes
- protected
- Definition Classes
- CirceTraitCodec
-
final
def
contramap[B](f: (B) ⇒ Ser): Encoder[B]
- Definition Classes
- Encoder
-
def
decodeAccumulating(c: HCursor): AccumulatingResult[Ser]
- Definition Classes
- Decoder
-
final
def
decodeJson(j: Json): Result[Ser]
- Definition Classes
- Decoder
-
final
def
either[B](decodeB: Decoder[B]): Decoder[Either[Ser, B]]
- Definition Classes
- Decoder
-
final
def
emap[B](f: (Ser) ⇒ Either[String, B]): Decoder[B]
- Definition Classes
- Decoder
-
final
def
emapTry[B](f: (Ser) ⇒ Try[B]): Decoder[B]
- Definition Classes
- Decoder
-
final
def
ensure(errors: (Ser) ⇒ List[String]): Decoder[Ser]
- Definition Classes
- Decoder
-
final
def
ensure(pred: (Ser) ⇒ Boolean, message: ⇒ String): Decoder[Ser]
- Definition Classes
- Decoder
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
lazy val
errorCallback: (String) ⇒ Unit
- Definition Classes
- CirceAkkaSerializer → CirceTraitCodec
-
final
def
flatMap[B](f: (Ser) ⇒ Decoder[B]): Decoder[B]
- Definition Classes
- Decoder
-
def
fromBinary(bytes: Array[Byte], manifest: String): AnyRef
- Definition Classes
- CirceAkkaSerializer → SerializerWithStringManifest
-
final
def
fromBinary(bytes: Array[Byte], manifest: Option[Class[_]]): AnyRef
- Definition Classes
- SerializerWithStringManifest → Serializer
-
final
def
fromBinary(bytes: Array[Byte], clazz: Class[_]): AnyRef
- Definition Classes
- Serializer
- Annotations
- @throws( ... )
-
final
def
fromBinary(bytes: Array[Byte]): AnyRef
- Definition Classes
- Serializer
-
def
genericCodec: Codec[Ser]
The intended usage of this method is to provide any form of support for generic classes.
The intended usage of this method is to provide any form of support for generic classes.
Because of type erasure, it's impossible to org.virtuslab.ash.circe.Register one generic class two times with different type parameters.
The trick for combating type erasure is to register generic class only once with type parameter being its upper bound, and provide custom made io.circe.Codec that can serialize/deserialize all classes that are used as a type parameter.
For example, if the upper bound is
Any, but you know that onlyIntandStringare used as a type parameter, then you can create a custom io.circe.Codec forAnythat handlesIntandStringand throwsExceptionotherwise.To use this method correctly, set the upper bound for the type parameter of generic class to
Serand put the returned Codec as implicit in a place that can be seen by type derivation.Example of generic class:
case class GenericClass[A <: MySerializable, B <: MySerializable](a: A, b: B) extends MySerializable
and its registration in serializer:
Register[GenericClass[MySerializable, MySerializable]]
- returns
io.circe.Codec that can serialize all subtypes of
Ser
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
handleErrorWith(f: (DecodingFailure) ⇒ Decoder[Ser]): Decoder[Ser]
- Definition Classes
- Decoder
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
iemap[B](f: (Ser) ⇒ Either[String, B])(g: (B) ⇒ Ser): Codec[B]
- Definition Classes
- Codec
-
def
iemapTry[B](f: (Ser) ⇒ Try[B])(g: (B) ⇒ Ser): Codec[B]
- Definition Classes
- Codec
-
final
def
includeManifest: Boolean
- Definition Classes
- SerializerWithStringManifest → Serializer
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
kleisli: Kleisli[Result, HCursor, Ser]
- Definition Classes
- Decoder
-
def
manifest(o: AnyRef): String
- Definition Classes
- CirceTraitCodec
-
val
manifestMigrationsMap: Map[String, String]
- Attributes
- protected
- Definition Classes
- CirceTraitCodec
-
final
def
map[B](f: (Ser) ⇒ B): Decoder[B]
- Definition Classes
- Decoder
-
final
def
mapJson(f: (Json) ⇒ Json): Encoder[Ser]
- Definition Classes
- Encoder
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
or[AA >: Ser](d: ⇒ Decoder[AA]): Decoder[AA]
- Definition Classes
- Decoder
-
final
def
prepare(f: (ACursor) ⇒ ACursor): Decoder[Ser]
- Definition Classes
- Decoder
-
final
def
product[B](fb: Decoder[B]): Decoder[(Ser, B)]
- Definition Classes
- Decoder
-
lazy val
shouldDoMissingCodecsCheck: Boolean
- Definition Classes
- CirceAkkaSerializer → CirceTraitCodec
-
implicit
def
sinkRefCodec[T](implicit system: ActorSystem = serializationSystem): Codec[SinkRef[T]]
- Definition Classes
- AkkaCodecs
-
implicit
def
sourceRefCodec[T](implicit system: ActorSystem = serializationSystem): Codec[SourceRef[T]]
- Definition Classes
- AkkaCodecs
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toBinary(o: AnyRef): Array[Byte]
- Definition Classes
- CirceAkkaSerializer → SerializerWithStringManifest → Serializer
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
tryDecode(c: ACursor): Result[Ser]
- Definition Classes
- Decoder
-
def
tryDecodeAccumulating(c: ACursor): AccumulatingResult[Ser]
- Definition Classes
- Decoder
-
final
def
validate(pred: (HCursor) ⇒ Boolean, message: ⇒ String): Decoder[Ser]
- Definition Classes
- Decoder
-
final
def
validate(errors: (HCursor) ⇒ List[String]): Decoder[Ser]
- Definition Classes
- Decoder
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
withErrorMessage(message: String): Decoder[Ser]
- Definition Classes
- Decoder