diff --git a/akka-persistence/src/main/scala/iw/akka/AkkaZioJsonSerializer.scala b/akka-persistence/src/main/scala/iw/akka/AkkaZioJsonSerializer.scala index 1f911e2..e62b257 100644 --- a/akka-persistence/src/main/scala/iw/akka/AkkaZioJsonSerializer.scala +++ b/akka-persistence/src/main/scala/iw/akka/AkkaZioJsonSerializer.scala @@ -8,7 +8,7 @@ class AkkaZioJsonSerializer[T <: AnyRef]( override val identifier: Int, manifestDiscriminator: T => String -)(using JsonCodec[T])(using ClassTag[T]) +)(using JsonCodec[T])(using ct: ClassTag[T]) extends SerializerWithStringManifest: override def manifest(o: AnyRef): String = @@ -16,7 +16,8 @@ case p: T => manifestDiscriminator(p) case _ => throw IllegalArgumentException( - s"Invalid object to serialize, expecting ProofEvent, got: ${o}" + s"Invalid object to serialize, expecting ${ct.runtimeClass + .getSimpleName()}, got: ${o}" ) override def toBinary(o: AnyRef): Array[Byte] = @@ -24,7 +25,8 @@ case p: T => p.toJson.getBytes("UTF-8") case _ => throw IllegalArgumentException( - s"Invalid object to serialize, expecting ProofEvent, got: ${o}" + s"Invalid object to serialize, expecting ${ct.runtimeClass + .getSimpleName()}, got: ${o}" ) override def fromBinary(o: Array[Byte], manifest: String): AnyRef = @@ -32,6 +34,6 @@ json.fromJson[T] match case Left(t) => throw IllegalStateException( - s"Unable to deserialize ProofEvent from $json: $t" + s"Unable to deserialize ${ct.runtimeClass.getSimpleName()} from $json: $t" ) case Right(e) => e diff --git a/akka-persistence/src/main/scala/iw/akka/AkkaZioJsonSerializer.scala b/akka-persistence/src/main/scala/iw/akka/AkkaZioJsonSerializer.scala index 1f911e2..e62b257 100644 --- a/akka-persistence/src/main/scala/iw/akka/AkkaZioJsonSerializer.scala +++ b/akka-persistence/src/main/scala/iw/akka/AkkaZioJsonSerializer.scala @@ -8,7 +8,7 @@ class AkkaZioJsonSerializer[T <: AnyRef]( override val identifier: Int, manifestDiscriminator: T => String -)(using JsonCodec[T])(using ClassTag[T]) +)(using JsonCodec[T])(using ct: ClassTag[T]) extends SerializerWithStringManifest: override def manifest(o: AnyRef): String = @@ -16,7 +16,8 @@ case p: T => manifestDiscriminator(p) case _ => throw IllegalArgumentException( - s"Invalid object to serialize, expecting ProofEvent, got: ${o}" + s"Invalid object to serialize, expecting ${ct.runtimeClass + .getSimpleName()}, got: ${o}" ) override def toBinary(o: AnyRef): Array[Byte] = @@ -24,7 +25,8 @@ case p: T => p.toJson.getBytes("UTF-8") case _ => throw IllegalArgumentException( - s"Invalid object to serialize, expecting ProofEvent, got: ${o}" + s"Invalid object to serialize, expecting ${ct.runtimeClass + .getSimpleName()}, got: ${o}" ) override def fromBinary(o: Array[Byte], manifest: String): AnyRef = @@ -32,6 +34,6 @@ json.fromJson[T] match case Left(t) => throw IllegalStateException( - s"Unable to deserialize ProofEvent from $json: $t" + s"Unable to deserialize ${ct.runtimeClass.getSimpleName()} from $json: $t" ) case Right(e) => e diff --git a/core/shared/src/main/scala/works/iterative/core/service/IdGenerator.scala b/core/shared/src/main/scala/works/iterative/core/service/IdGenerator.scala index f905eba..1779da3 100644 --- a/core/shared/src/main/scala/works/iterative/core/service/IdGenerator.scala +++ b/core/shared/src/main/scala/works/iterative/core/service/IdGenerator.scala @@ -4,4 +4,7 @@ /** Generator of unique IDs of a given type */ trait IdGenerator[A]: + self => def nextId: UIO[A] + def map[B](f: A => B): IdGenerator[B] = new IdGenerator[B]: + def nextId: UIO[B] = self.nextId.map(f)