Browse Source

server: Add ExternalServiceExecutionContext

scalafmt-draft
Alexis Hernandez 7 years ago
parent
commit
723b1c7911
  1. 15
      server/app/com/xsn/explorer/executors/ExternalServiceExecutionContext.scala
  2. 8
      server/conf/application.conf
  3. 16
      server/test/com/xsn/explorer/helpers/Executors.scala

15
server/app/com/xsn/explorer/executors/ExternalServiceExecutionContext.scala

@ -0,0 +1,15 @@
package com.xsn.explorer.executors
import javax.inject.{Inject, Singleton}
import akka.actor.ActorSystem
import play.api.libs.concurrent.CustomExecutionContext
import scala.concurrent.ExecutionContext
trait ExternalServiceExecutionContext extends ExecutionContext
@Singleton
class ExternalServiceAkkaExecutionContext @Inject()(system: ActorSystem)
extends CustomExecutionContext(system, "externalService.dispatcher")
with ExternalServiceExecutionContext

8
server/conf/application.conf

@ -24,3 +24,11 @@ rpc {
}
play.modules.enabled += "com.xsn.explorer.modules.ConfigModule"
externalService.dispatcher {
executor = "thread-pool-executor"
throughput = 1
thread-pool-executor {
fixed-pool-size = 50
}
}

16
server/test/com/xsn/explorer/helpers/Executors.scala

@ -0,0 +1,16 @@
package com.xsn.explorer.helpers
import com.xsn.explorer.executors.ExternalServiceExecutionContext
import scala.concurrent.ExecutionContext
object Executors {
implicit val globalEC: ExecutionContext = scala.concurrent.ExecutionContext.global
implicit val externalServiceEC: ExternalServiceExecutionContext = new ExternalServiceExecutionContext {
override def execute(runnable: Runnable): Unit = globalEC.execute(runnable)
override def reportFailure(cause: Throwable): Unit = globalEC.reportFailure(cause)
}
}
Loading…
Cancel
Save