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

codacy.events.internal.Handlers.scala Maven / Gradle / Ivy

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]
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy