codacy.events.internal.Handlers.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of events-rabbitmq_2.13 Show documentation
Show all versions of events-rabbitmq_2.13 Show documentation
A library to send events on rabbit-mq
The newest version!
package codacy.events.internal
import io.circe.Json
import shapeless.{:+:, lazily, CNil, Coproduct, Lazy}
import codacy.events._
import scala.concurrent.Future
sealed trait Handlers[C] extends Any {
def handlers: List[Handlers.RequestHandler]
}
object Handlers {
type RequestHandler = (String, (String, Json) => Future[Unit])
implicit def caseCNil: Handlers[CNil] = Impl(List.empty)
implicit def caseCCons[H <: Event, T <: Coproduct](implicit
h: Lazy[EventHandler[H]],
t: Lazy[Handlers[T]]
): Handlers[H :+: T] = {
Impl(lazily[Handlers[T]].handlers :+ lazily[EventHandler[H]].generic)
}
private case class Impl[T](handlers: List[RequestHandler]) extends AnyVal with Handlers[T]
}