new actor map for round socket hub

pull/4569/head
Thibault Duplessis 2018-08-25 11:12:52 +02:00
parent 2a1dc5f360
commit 05e7c16a9a
11 changed files with 22 additions and 25 deletions

View File

@ -411,7 +411,7 @@ round {
ragequit.timeout = 10 seconds ragequit.timeout = 10 seconds
} }
socket { socket {
name = round-socket name = round-socket-front
timeout = 30 seconds timeout = 30 seconds
} }
channel.move_time.name = round-move-time-channel channel.move_time.name = round-move-time-channel

View File

@ -25,7 +25,7 @@ final class Env(
lazy val analyser = new Analyser( lazy val analyser = new Analyser(
indexer = indexer, indexer = indexer,
requesterApi = requesterApi, requesterApi = requesterApi,
roundSocket = hub.socket.round, roundSocket = hub.socket.roundActor,
studyActor = hub.actor.study, studyActor = hub.actor.study,
bus = system.lilaBus bus = system.lilaBus
) )

View File

@ -14,7 +14,7 @@ final class Env(
lazy val gameStateStream = new GameStateStream( lazy val gameStateStream = new GameStateStream(
system, system,
jsonView, jsonView,
hub.socket.round hub.socket.roundActor
) )
lazy val player = new BotPlayer(hub.actor.chat)(system) lazy val player = new BotPlayer(hub.actor.chat)(system)

View File

@ -61,7 +61,7 @@ final class Env(
import lila.hub.actorApi.map.Exists import lila.hub.actorApi.map.Exists
import akka.pattern.ask import akka.pattern.ask
import makeTimeout.short import makeTimeout.short
hub.socket.round ? Exists(id) mapTo manifest[Boolean] hub.socket.roundActor ? Exists(id) mapTo manifest[Boolean]
}, },
clientVersion = clientVersion, clientVersion = clientVersion,
offlineMode = OfflineMode, offlineMode = OfflineMode,

View File

@ -35,7 +35,7 @@ final class Env(config: Config, system: ActorSystem) {
object socket { object socket {
val lobby = select("socket.lobby") val lobby = select("socket.lobby")
val round = select("socket.round") val roundActor = select("socket.round")
val site = select("socket.site") val site = select("socket.site")
val hub = select("socket.hub") val hub = select("socket.hub")
} }

View File

@ -54,7 +54,7 @@ object Env {
db = lila.db.Env.current, db = lila.db.Env.current,
system = lila.common.PlayApp.system, system = lila.common.PlayApp.system,
getLightUser = lila.user.Env.current.lightUserSync, getLightUser = lila.user.Env.current.lightUserSync,
roundSocketHub = lila.hub.Env.current.socket.round, roundSocketHub = lila.hub.Env.current.socket.roundActor,
scheduler = lila.common.PlayApp.scheduler, scheduler = lila.common.PlayApp.scheduler,
config = lila.common.PlayApp loadConfig "push" config = lila.common.PlayApp loadConfig "push"
) )

View File

@ -1,7 +1,7 @@
package lila.round package lila.round
import akka.actor._ import akka.actor._
import akka.pattern.ask
import org.joda.time.DateTime import org.joda.time.DateTime
import play.api.libs.iteratee._ import play.api.libs.iteratee._
import reactivemongo.api._ import reactivemongo.api._
@ -15,7 +15,7 @@ import makeTimeout.short
private final class CorresAlarm( private final class CorresAlarm(
coll: Coll, coll: Coll,
roundSocketHub: ActorSelection socketHub: lila.hub.ActorMapNew
) extends Actor { ) extends Actor {
object Schedule object Schedule
@ -56,7 +56,7 @@ private final class CorresAlarm(
case (count, alarm) => GameRepo.game(alarm._id).flatMap { case (count, alarm) => GameRepo.game(alarm._id).flatMap {
_ ?? { game => _ ?? { game =>
val pov = Pov(game, game.turnColor) val pov = Pov(game, game.turnColor)
roundSocketHub ? Ask(pov.gameId, IsOnGame(pov.color)) mapTo manifest[Boolean] addEffect { socketHub.ask[Boolean](pov.gameId, IsOnGame(pov.color)) addEffect {
case true => // already looking at the game case true => // already looking at the game
case false => context.system.lilaBus.publish( case false => context.system.lilaBus.publish(
lila.game.actorApi.CorresAlarmEvent(pov), lila.game.actorApi.CorresAlarmEvent(pov),

View File

@ -1,14 +1,14 @@
package lila.round package lila.round
import akka.actor._ import akka.actor._
import akka.pattern.ask import akka.pattern.{ ask, pipe }
import com.typesafe.config.Config import com.typesafe.config.Config
import scala.concurrent.duration._ import scala.concurrent.duration._
import actorApi.{ GetSocketStatus, SocketStatus } import actorApi.{ GetSocketStatus, SocketStatus }
import lila.game.{ Game, GameRepo, Pov } import lila.game.{ Game, GameRepo, Pov }
import lila.hub.actorApi.map.{ Ask, Tell } import lila.hub.actorApi.map.{ Tell, Exists, Ask }
import lila.hub.actorApi.round.{ Abort, Resign, FishnetPlay } import lila.hub.actorApi.round.{ Abort, Resign, FishnetPlay }
import lila.hub.actorApi.{ HasUserId, DeployPost } import lila.hub.actorApi.{ HasUserId, DeployPost }
@ -128,6 +128,11 @@ final class Env(
logger.warn("Disabling round history persistence!") logger.warn("Disabling round history persistence!")
historyPersistenceEnabled = false historyPersistenceEnabled = false
} }
case Tell(id, msg) => socketHub.tell(id, msg)
case Exists(id) => sender ! socketHub.exists(id)
case Ask(id, msg) =>
import makeTimeout.short
socketHub.getOrMake(id) ? msg pipeTo sender
} }
}), name = SocketName) }), name = SocketName)
bus.subscribe(socketHubActor, 'tvSelect, 'startGame, 'deploy) bus.subscribe(socketHubActor, 'tvSelect, 'startGame, 'deploy)
@ -232,7 +237,7 @@ final class Env(
) )
bus.subscribe(system.actorOf( bus.subscribe(system.actorOf(
Props(new CorresAlarm(db(CollectionAlarm), hub.socket.round)), Props(new CorresAlarm(db(CollectionAlarm), socketHub)),
name = "corres-alarm" name = "corres-alarm"
), 'moveEventCorres, 'finishGame) ), 'moveEventCorres, 'finishGame)

View File

@ -21,7 +21,6 @@ final class Env(
flood: lila.security.Flood, flood: lila.security.Flood,
hub: lila.hub.Env, hub: lila.hub.Env,
roundMap: DuctMap[_], roundMap: DuctMap[_],
roundSocketHub: ActorSelection,
lightUserApi: lila.user.LightUserApi, lightUserApi: lila.user.LightUserApi,
isOnline: String => Boolean, isOnline: String => Boolean,
onStart: String => Unit, onStart: String => Unit,
@ -217,7 +216,6 @@ object Env {
flood = lila.security.Env.current.flood, flood = lila.security.Env.current.flood,
hub = lila.hub.Env.current, hub = lila.hub.Env.current,
roundMap = lila.round.Env.current.roundMap, roundMap = lila.round.Env.current.roundMap,
roundSocketHub = lila.hub.Env.current.socket.round,
lightUserApi = lila.user.Env.current.lightUserApi, lightUserApi = lila.user.Env.current.lightUserApi,
isOnline = lila.user.Env.current.isOnline, isOnline = lila.user.Env.current.isOnline,
onStart = lila.game.Env.current.onStart, onStart = lila.game.Env.current.onStart,

View File

@ -2,6 +2,7 @@ package lila.tv
import akka.actor._ import akka.actor._
import com.typesafe.config.Config import com.typesafe.config.Config
import scala.concurrent.duration._
import lila.db.dsl._ import lila.db.dsl._
import lila.game.Game import lila.game.Game
@ -11,7 +12,7 @@ import scala.concurrent.duration._
final class Env( final class Env(
config: Config, config: Config,
db: lila.db.Env, db: lila.db.Env,
hub: lila.hub.Env, renderer: ActorSelection,
lightUser: lila.common.LightUser.GetterSync, lightUser: lila.common.LightUser.GetterSync,
roundProxyGame: Game.ID => Fu[Option[Game]], roundProxyGame: Game.ID => Fu[Option[Game]],
system: ActorSystem, system: ActorSystem,
@ -25,18 +26,12 @@ final class Env(
private val selectChannel = system.actorOf(Props(classOf[lila.socket.Channel]), name = ChannelSelect) private val selectChannel = system.actorOf(Props(classOf[lila.socket.Channel]), name = ChannelSelect)
private val tvActor = system.actorOf( private val tvActor = system.actorOf(
Props(new TvActor(hub.actor.renderer, hub.socket.round, selectChannel, lightUser, onSelect)) Props(new TvActor(renderer, selectChannel, lightUser, onSelect))
) )
lazy val tv = new Tv(tvActor, roundProxyGame) lazy val tv = new Tv(tvActor, roundProxyGame)
{ scheduler.message(FeaturedSelect) { tvActor -> TvActor.Select }
import scala.concurrent.duration._
scheduler.message(FeaturedSelect) {
tvActor -> TvActor.Select
}
}
} }
object Env { object Env {
@ -44,7 +39,7 @@ object Env {
lazy val current = "tv" boot new Env( lazy val current = "tv" boot new Env(
config = lila.common.PlayApp loadConfig "tv", config = lila.common.PlayApp loadConfig "tv",
db = lila.db.Env.current, db = lila.db.Env.current,
hub = lila.hub.Env.current, renderer = lila.hub.Env.current.actor.renderer,
lightUser = lila.user.Env.current.lightUserSync, lightUser = lila.user.Env.current.lightUserSync,
roundProxyGame = lila.round.Env.current.roundProxyGame _, roundProxyGame = lila.round.Env.current.roundProxyGame _,
system = lila.common.PlayApp.system, system = lila.common.PlayApp.system,

View File

@ -10,7 +10,6 @@ import lila.game.{ Game, GameRepo }
private[tv] final class TvActor( private[tv] final class TvActor(
rendererActor: ActorSelection, rendererActor: ActorSelection,
roundSocket: ActorSelection,
selectChannel: ActorRef, selectChannel: ActorRef,
lightUser: LightUser.GetterSync, lightUser: LightUser.GetterSync,
onSelect: Game => Unit onSelect: Game => Unit