Skip to content

Commit

Permalink
Merge pull request #243 from schlawg/master
Browse files Browse the repository at this point in the history
make lila-fishnet build
  • Loading branch information
ornicar authored Nov 10, 2023
2 parents c8f5e81 + 5fffdbb commit ba6590f
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 21 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.bloop/
.metals/
logs/
project/metals.sbt
project/project/
target/
RUNNING_PID
# docker sbt
Expand Down
16 changes: 9 additions & 7 deletions app/AppLoader.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package lila.app

import play.api._
import scala.annotation.nowarn
import play.api.routing.Router
import router.Routes
import play.api.routing.{ Router, SimpleRouter }
import play.api.routing.sird._
import akka.actor.ActorSystem

final class AppLoader extends ApplicationLoader {
def load(ctx: ApplicationLoader.Context): Application = new LilaComponents(ctx).application
Expand All @@ -25,16 +25,18 @@ final class LilaComponents(ctx: ApplicationLoader.Context) extends BuiltInCompon

import _root_.controllers._

implicit def system = actorSystem
implicit def system: ActorSystem = actorSystem

lazy val moveDb = new lila.fishnet.MoveDb
lazy val redis = new lila.fishnet.Lila(moveDb, configuration)
lazy val controller = new FishnetController(configuration, redis, moveDb, controllerComponents)

// eagerly wire up all controllers
val router: Router = {
@nowarn val prefix: String = "/"
new Routes(httpErrorHandler, controller)
val router: Router = new SimpleRouter {
def routes: Router.Routes = {
case POST(p"/fishnet/acquire") => controller.acquire
case POST(p"/fishnet/move/$workId") => controller.move(workId)
}
}

if (configuration.get[Boolean]("kamon.enabled")) {
Expand Down
18 changes: 9 additions & 9 deletions app/JsonApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,20 @@ object JsonApi {
def moveFromWork(m: Work.Move) = Move(m.id.value, m.level, fromGame(m.game), m.clock)

object readers {
implicit val ClientKeyReads = Reads.of[String].map(new ClientKey(_))
implicit val FishnetReads = Json.reads[Request.Fishnet]
implicit val AcquireReads = Json.reads[Request.Acquire]
implicit val MoveResultReads = Json.reads[Request.MoveResult]
implicit val PostMoveReads = Json.reads[Request.PostMove]
implicit val ClientKeyReads: Reads[ClientKey] = Reads.of[String].map(new ClientKey(_))
implicit val FishnetReads: Reads[Request.Fishnet] = Json.reads[Request.Fishnet]
implicit val AcquireReads: Reads[Request.Acquire] = Json.reads[Request.Acquire]
implicit val MoveResultReads: Reads[Request.MoveResult] = Json.reads[Request.MoveResult]
implicit val PostMoveReads: Reads[Request.PostMove] = Json.reads[Request.PostMove]
}

object writers {
implicit val VariantWrites = Writes[Variant] { v => JsString(v.key) }
implicit val FENWrites = Writes[FEN] { fen => JsString(fen.value) }
implicit val VariantWrites: Writes[Variant] = Writes[Variant] { v => JsString(v.key) }
implicit val FENWrites: Writes[FEN] = Writes[FEN] { fen => JsString(fen.value) }
implicit val GameWrites: Writes[Game] = Json.writes[Game]
implicit val ClockWrites: Writes[Work.Clock] = Json.writes[Work.Clock]
implicit val WorkIdWrites = Writes[Work.Id] { id => JsString(id.value) }
implicit val WorkWrites = OWrites[Work] { work =>
implicit val WorkIdWrites: Writes[Work.Id] = Writes[Work.Id] { id => JsString(id.value) }
implicit val WorkWrites: OWrites[Work] = OWrites[Work] { work =>
(work match {
case m: Move =>
Json.obj(
Expand Down
1 change: 0 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ maintainer := "lichess.org"

lazy val root = Project("lila-fishnet", file("."))
.enablePlugins(PlayScala, PlayNettyServer)
.disablePlugins(PlayAkkaHttpServer)

scalaVersion := "2.13.12"
Compile / resourceDirectory := baseDirectory.value / "conf"
Expand Down
2 changes: 0 additions & 2 deletions conf/routes

This file was deleted.

2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.7.2
sbt.version=1.9.7
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ resolvers += Resolver.url(
"lila-maven-sbt",
url("https://raw.githubusercontent.com/ornicar/lila-maven/master")
)(Resolver.ivyStylePatterns)
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.18")
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.18-lila_1.21")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")

0 comments on commit ba6590f

Please sign in to comment.