live setting to disable the round API load balancer
This commit is contained in:
parent
7331d3f938
commit
7539802b67
|
@ -14,7 +14,8 @@ object Dev extends LilaController {
|
|||
Env.irwin.irwinModeSetting,
|
||||
Env.api.assetVersionSetting,
|
||||
Env.explorer.indexFlowSetting,
|
||||
Env.report.scoreThresholdSetting
|
||||
Env.report.scoreThresholdSetting,
|
||||
Env.api.roundRouterSetting
|
||||
)
|
||||
|
||||
def settings = Secure(_.Settings) { implicit ctx => me =>
|
||||
|
|
|
@ -64,6 +64,11 @@ final class Env(
|
|||
text = "Assets version. Increment to force all clients to load a new version of static assets. Decrement to serve a previous revision of static assets.".some,
|
||||
init = (config, db) => config.value max db.value
|
||||
)
|
||||
val roundRouterSetting = settingStore[Boolean](
|
||||
"roundRouter",
|
||||
default = true,
|
||||
text = "enable round router".some
|
||||
)
|
||||
|
||||
object Accessibility {
|
||||
val blindCookieName = config getString "accessibility.blind.cookie.name"
|
||||
|
@ -116,6 +121,7 @@ final class Env(
|
|||
getTourAndRanks = getTourAndRanks,
|
||||
getSimul = getSimul
|
||||
),
|
||||
enabled = roundRouterSetting.get,
|
||||
system = system,
|
||||
nbActors = math.max(1, math.min(16, Runtime.getRuntime.availableProcessors - 1))
|
||||
)
|
||||
|
|
|
@ -16,7 +16,8 @@ import lila.user.User
|
|||
private[api] final class RoundApiBalancer(
|
||||
system: ActorSystem,
|
||||
api: RoundApi,
|
||||
nbActors: Int
|
||||
nbActors: Int,
|
||||
enabled: () => Boolean
|
||||
) {
|
||||
|
||||
private val logger = lila.log("round").branch("balancer")
|
||||
|
@ -66,9 +67,12 @@ private[api] final class RoundApiBalancer(
|
|||
import implementation._
|
||||
|
||||
def player(pov: Pov, apiVersion: ApiVersion)(implicit ctx: Context): Fu[JsObject] = {
|
||||
router ? Player(pov, apiVersion, ctx) mapTo manifest[JsObject] addFailureEffect { e =>
|
||||
if (enabled()) router ? Player(pov, apiVersion, ctx) mapTo manifest[JsObject] addFailureEffect { e =>
|
||||
logger.error(pov.toString, e)
|
||||
}
|
||||
else api.player(pov, apiVersion)(ctx) addFailureEffect { e =>
|
||||
logger.error(s"player ${pov.toString}", e)
|
||||
}
|
||||
}.chronometer
|
||||
.mon(_.round.api.player)
|
||||
.logIfSlow(500, logger) { _ => s"outer player $pov" }
|
||||
|
@ -76,7 +80,8 @@ private[api] final class RoundApiBalancer(
|
|||
|
||||
def watcher(pov: Pov, apiVersion: ApiVersion, tv: Option[lila.round.OnTv],
|
||||
initialFenO: Option[Option[FEN]] = None)(implicit ctx: Context): Fu[JsObject] = {
|
||||
router ? Watcher(pov, apiVersion, tv, initialFenO, ctx) mapTo manifest[JsObject]
|
||||
if (enabled()) router ? Watcher(pov, apiVersion, tv, initialFenO, ctx) mapTo manifest[JsObject]
|
||||
else api.watcher(pov, apiVersion, tv, initialFenO)(ctx)
|
||||
}.mon(_.round.api.watcher)
|
||||
|
||||
def review(pov: Pov, apiVersion: ApiVersion,
|
||||
|
@ -84,12 +89,15 @@ private[api] final class RoundApiBalancer(
|
|||
analysis: Option[Analysis] = None,
|
||||
initialFenO: Option[Option[FEN]] = None,
|
||||
withFlags: WithFlags)(implicit ctx: Context): Fu[JsObject] = {
|
||||
router ? Review(pov, apiVersion, tv, analysis, initialFenO, withFlags, ctx) mapTo manifest[JsObject]
|
||||
if (enabled()) router ? Review(pov, apiVersion, tv, analysis, initialFenO, withFlags, ctx) mapTo manifest[JsObject]
|
||||
else api.review(pov, apiVersion, tv, analysis, initialFenO, withFlags)(ctx)
|
||||
}.mon(_.round.api.watcher)
|
||||
|
||||
def userAnalysisJson(pov: Pov, pref: Pref, initialFen: Option[FEN], orientation: chess.Color, owner: Boolean, me: Option[User]): Fu[JsObject] =
|
||||
router ? UserAnalysis(pov, pref, initialFen, orientation, owner, me) mapTo manifest[JsObject]
|
||||
if (enabled()) router ? UserAnalysis(pov, pref, initialFen, orientation, owner, me) mapTo manifest[JsObject]
|
||||
else api.userAnalysisJson(pov, pref, initialFen, orientation, owner, me)
|
||||
|
||||
def freeStudyJson(pov: Pov, pref: Pref, initialFen: Option[FEN], orientation: chess.Color, me: Option[User]): Fu[JsObject] =
|
||||
router ? FreeStudy(pov, pref, initialFen, orientation, me) mapTo manifest[JsObject]
|
||||
if (enabled()) router ? FreeStudy(pov, pref, initialFen, orientation, me) mapTo manifest[JsObject]
|
||||
else fuccess(api.freeStudyJson(pov, pref, initialFen, orientation, me))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue