Install dependency
resolvers += Resolver.jcenterRepo
libraryDependencies += "com.iheart" %% "kanaloa-core" % "0.5.0"
Use proxy
import kanaloa._
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
val proxyFactory = ReverseProxyFactory()
// proxyFactory: kanaloa.ReverseProxyFactory = kanaloa.ReverseProxyFactory@14138d3d
//assuming this is your service
val service = (i: Int) => Future(i.toString)
// service: Int => scala.concurrent.Future[String] = <function1>
val proxy: Int => Future[Either[WorkException, String]] = proxyFactory(service)
// proxy: Int => scala.concurrent.Future[Either[kanaloa.WorkException,String]] = <function1>
//voilĂ , you have a super resilient toString service now.
val result = proxy(42)
// result: scala.concurrent.Future[Either[kanaloa.WorkException,String]] = List()
result.foreach(println)
Right(42)
Thread.sleep(100) //job done! let's shutdown the system
proxyFactory.close()
Config kanaloa [Optional]
An example of a my-service1
kanaloa {
dispatchers {
my-service1 {
worker-pool {
starting-pool-size = 50
}
}
}
}
For more configuration settings and their documentation please see the reference configuration