我們如何在代碼中自動查找調度程式src/main/resources/application.conf的地方使用相同的dedicated dispatcherapplication.conf
uj5u.com熱心網友回復:
這是您可以放入您的執行背景關系的兩個示例配置application.conf:
background-scheduled-tasks-dispatcher {
type = Dispatcher
executor = "fork-join-executor"
fork-join-executor {
parallelism-min = 2
parallelism-factor = 2.0
parallelism-max = 10
}
throughput = 1
}
blocking-io-ec {
type = Dispatcher
executor = "thread-pool-executor"
thread-pool-executor {
fixed-pool-size = 50
}
throughput = 1
}
以下是如何在您的應用程式中訪問其中一個的示例:
val ec :ExecutionContext = actorSystem.dispatchers.lookup("blocking-io-ec")
您可以為該行添加前綴,implicit val ec也可以顯式使用它
someFuture.map(myFunc)(ec)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/529603.html
上一篇:Scala:提取檔案路徑的一部分
下一篇:Quill找不到案例類屬性
