Skip to content

Commit

Permalink
make explorer.index_flow a runtime setting
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Dec 1, 2017
1 parent 9542440 commit 456d690
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/controllers/Dev.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ object Dev extends LilaController {
private lazy val settingsList = List[lila.memo.SettingStore[_]](
Env.security.ugcArmedSetting,
Env.irwin.irwinArmedSetting,
Env.api.assetVersionSetting
Env.api.assetVersionSetting,
Env.explorer.indexFlowSetting
)

def settings = Secure(_.Settings) { implicit ctx => me =>
Expand Down
1 change: 0 additions & 1 deletion conf/base.conf
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@ tv {
explorer {
endpoint = "https://expl.lichess.org"
internal_endpoint = "http:https://expl.lichess.org"
index_flow = false
tablebase = {
endpoint = "https://tablebase.lichess.org"
}
Expand Down
12 changes: 10 additions & 2 deletions modules/explorer/src/main/Env.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ final class Env(
config: Config,
gameColl: lila.db.dsl.Coll,
gameImporter: lila.importer.Importer,
settingStore: lila.memo.SettingStore.Builder,
system: ActorSystem
) {

Expand All @@ -29,9 +30,15 @@ final class Env(
}
}

if (IndexFlow) system.lilaBus.subscribe(system.actorOf(Props(new Actor {
lazy val indexFlowSetting = settingStore[Boolean](
"explorerIndexFlow",
default = true,
text = "Explorer: index new games as soon as they complete".some
)

system.lilaBus.subscribe(system.actorOf(Props(new Actor {
def receive = {
case lila.game.actorApi.FinishGame(game, _, _) if !game.aborted => indexer(game)
case lila.game.actorApi.FinishGame(game, _, _) if !game.aborted && indexFlowSetting.get() => indexer(game)
}
})), 'finishGame)
}
Expand All @@ -42,6 +49,7 @@ object Env {
config = lila.common.PlayApp loadConfig "explorer",
gameColl = lila.game.Env.current.gameColl,
gameImporter = lila.importer.Env.current.importer,
settingStore = lila.memo.Env.current.settingStore,
system = lila.common.PlayApp.system
)
}

0 comments on commit 456d690

Please sign in to comment.