Skip to content

Commit

Permalink
use http for server to server explorer requests
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Jun 12, 2016
1 parent 1d33d42 commit 1d88687
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
4 changes: 1 addition & 3 deletions conf/base.conf
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,8 @@ tv {
}
explorer {
endpoint = "https://expl.lichess.org"
internal_endpoint = "http:https://expl.lichess.org"
index_flow = false
mass_import = {
endpoint = "https://expl.lichess.org"
}
tablebase = {
endpoint = "https://expl.lichess.org/tablebase"
}
Expand Down
6 changes: 3 additions & 3 deletions modules/explorer/src/main/Env.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ final class Env(
system: ActorSystem) {

private val Endpoint = config getString "endpoint"
private val MassImportEndpoint = config getString "mass_import.endpoint"
private val InternalEndpoint = config getString "internal_endpoint"
private val IndexFlow = config getBoolean "index_flow"

private lazy val indexer = new ExplorerIndexer(
gameColl = gameColl,
endpoint = Endpoint,
massImportEndpoint = MassImportEndpoint)
internalEndpoint = InternalEndpoint)

def cli = new lila.common.Cli {
def process = {
Expand All @@ -26,7 +26,7 @@ final class Env(
def fetchPgn(id: String): Fu[Option[String]] = {
import play.api.libs.ws.WS
import play.api.Play.current
WS.url(s"$Endpoint/master/pgn/$id").get() map {
WS.url(s"$InternalEndpoint/master/pgn/$id").get() map {
case res if res.status == 200 => res.body.some
case _ => None
}
Expand Down
10 changes: 4 additions & 6 deletions modules/explorer/src/main/ExplorerIndexer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import lila.user.UserRepo

private final class ExplorerIndexer(
gameColl: Coll,
endpoint: String,
massImportEndpoint: String) {
internalEndpoint: String) {

private val maxGames = Int.MaxValue
private val batchSize = 50
Expand All @@ -28,8 +27,7 @@ private final class ExplorerIndexer(
private val dateFormatter = DateTimeFormat forPattern datePattern
private val dateTimeFormatter = DateTimeFormat forPattern s"$datePattern HH:mm"
private val pgnDateFormat = DateTimeFormat forPattern "yyyy.MM.dd";
private val endPointUrl = s"$endpoint/import/lichess"
private val massImportEndPointUrl = s"$massImportEndpoint/import/lichess"
private val internalEndPointUrl = s"$internalEndpoint/import/lichess"

private def parseDate(str: String): Option[DateTime] =
Try(dateFormatter parseDateTime str).toOption
Expand Down Expand Up @@ -60,7 +58,7 @@ private final class ExplorerIndexer(
Enumeratee.grouped(Iteratee takeUpTo batchSize) |>>>
Iteratee.foldM[Seq[GamePGN], Long](nowMillis) {
case (millis, pairs) =>
WS.url(massImportEndPointUrl).put(pairs.map(_._2) mkString separator).flatMap {
WS.url(internalEndPointUrl).put(pairs.map(_._2) mkString separator).flatMap {
case res if res.status == 200 =>
val date = pairs.headOption.map(_._1.createdAt) ?? dateTimeFormatter.print
val nb = pairs.size
Expand Down Expand Up @@ -90,7 +88,7 @@ private final class ExplorerIndexer(
buf += pgn
val startAt = nowMillis
if (buf.size >= max) {
WS.url(endPointUrl).put(buf mkString separator) andThen {
WS.url(internalEndPointUrl).put(buf mkString separator) andThen {
case Success(res) if res.status == 200 =>
lila.mon.explorer.index.time(((nowMillis - startAt) / max).toInt)
lila.mon.explorer.index.success(max)
Expand Down

0 comments on commit 1d88687

Please sign in to comment.