more sub projects
This commit is contained in:
parent
30bd385a93
commit
eb95291690
|
@ -3,7 +3,7 @@ package analyse
|
|||
|
||||
import scala.concurrent.duration._
|
||||
|
||||
import memo.ActorMemo
|
||||
import lila.common.memo.ActorMemo
|
||||
|
||||
final class Cached(
|
||||
analysisRepo: AnalysisRepo,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package lila.app
|
||||
package forum
|
||||
|
||||
import memo.Builder
|
||||
import lila.common.memo.Builder
|
||||
import user.User
|
||||
import security.{ Permission, Granter }
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package game
|
|||
|
||||
import scala.concurrent.duration._
|
||||
|
||||
import memo.ActorMemo
|
||||
import lila.common.memo.ActorMemo
|
||||
|
||||
private[game] final class Cached(
|
||||
gameRepo: GameRepo,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package lila.app
|
||||
package http
|
||||
|
||||
import ui.Theme
|
||||
import user.UserRepo
|
||||
import lila.user.Theme
|
||||
import lila.user.UserRepo
|
||||
|
||||
import scalaz.effects._
|
||||
import play.api.mvc.Cookie
|
||||
|
|
|
@ -2,7 +2,7 @@ package lila.app
|
|||
package lobby
|
||||
|
||||
import game.DbGame
|
||||
import memo.BooleanExpiryMemo
|
||||
import lila.common.memo.BooleanExpiryMemo
|
||||
|
||||
import scalaz.effects._
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import round.{ Socket ⇒ RoundSocket, Messenger ⇒ RoundMessenger }
|
|||
import socket.History
|
||||
import security.Flood
|
||||
import core.Settings
|
||||
import memo.BooleanExpiryMemo
|
||||
import lila.common.memo.BooleanExpiryMemo
|
||||
|
||||
final class LobbyEnv(
|
||||
app: Application,
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
package lila.app
|
||||
package mongodb
|
||||
|
||||
import com.mongodb.casbah.MongoCollection
|
||||
import com.mongodb.casbah.Imports._
|
||||
|
||||
import scala.reflect.{ClassTag, classTag}
|
||||
|
||||
final class Cache(collection: MongoCollection) {
|
||||
|
||||
private val field = "v"
|
||||
|
||||
def set(key: String, value: Any): Unit = {
|
||||
collection += DBObject("_id" -> key, field -> value)
|
||||
}
|
||||
|
||||
def get(key: String): Option[Any] = for {
|
||||
o ← collection.findOne(select(key))
|
||||
v ← Option(o get field)
|
||||
} yield v
|
||||
|
||||
def getAs[T : ClassTag](key: String): Option[T] = for {
|
||||
v ← get(key)
|
||||
} yield v.asInstanceOf[T]
|
||||
|
||||
def remove(key: String) {
|
||||
collection remove select(key)
|
||||
}
|
||||
|
||||
private def select(key: String) = DBObject("_id" -> key)
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package lila.app
|
||||
package mongodb
|
||||
|
||||
import lila.app.core.Global
|
||||
|
||||
import play.api.Application
|
||||
import play.api.cache.{ CacheAPI, CachePlugin => PlayCachePlugin }
|
||||
|
||||
class CachePlugin(app: Application) extends PlayCachePlugin {
|
||||
|
||||
lazy val cache = Global.env.mongodb.cache
|
||||
|
||||
lazy val api = new CacheAPI {
|
||||
|
||||
def set(key: String, value: Any, expiration: Int) {
|
||||
cache.set(key, value)
|
||||
}
|
||||
|
||||
def get(key: String): Option[Any] = cache get key
|
||||
|
||||
def remove(key: String) {
|
||||
cache remove key
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
package lila
|
||||
|
||||
import ornicar.scalalib
|
||||
|
||||
import com.novus.salat.{ Context, TypeHintFrequency, StringTypeHintStrategy }
|
||||
import com.mongodb.casbah.commons.conversions.scala.RegisterJodaTimeConversionHelpers
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package lila.app
|
|||
package round
|
||||
|
||||
import game.DbGame
|
||||
import memo.BooleanExpiryMemo
|
||||
import lila.common.memo.BooleanExpiryMemo
|
||||
|
||||
import scalaz.effects._
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import play.api.libs.json._
|
|||
import scalaz.effects._
|
||||
|
||||
import chess.Color
|
||||
import memo.Builder
|
||||
import lila.common.memo.Builder
|
||||
|
||||
case class VersionedEvent(
|
||||
version: Int,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package lila.app
|
||||
package security
|
||||
|
||||
import memo.Builder
|
||||
import lila.common.memo.Builder
|
||||
|
||||
import org.joda.time.DateTime
|
||||
import org.scala_tools.time.Imports._
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package lila.app
|
||||
package setup
|
||||
|
||||
import memo.Builder
|
||||
import lila.common.memo.Builder
|
||||
|
||||
import scalaz.effects._
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import scala.math.max
|
|||
import play.api.libs.json._
|
||||
import scalaz.effects._
|
||||
|
||||
import memo.Builder
|
||||
import lila.common.memo.Builder
|
||||
|
||||
final class History(timeout: Int) {
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package lila.app
|
||||
package socket
|
||||
|
||||
import memo.BooleanExpiryMemo
|
||||
import lila.common.memo.BooleanExpiryMemo
|
||||
|
||||
import akka.actor._
|
||||
import play.api.libs.json._
|
||||
|
|
|
@ -2,7 +2,7 @@ package lila.app
|
|||
package templating
|
||||
|
||||
import http.{ Context, Setting }
|
||||
import ui.Theme
|
||||
import lila.user.Theme
|
||||
|
||||
import play.api.templates.Html
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package tournament
|
|||
|
||||
import game.DbGame
|
||||
import socket._
|
||||
import memo.BooleanExpiryMemo
|
||||
import lila.common.memo.BooleanExpiryMemo
|
||||
|
||||
import akka.actor._
|
||||
import scala.concurrent.duration._
|
||||
|
|
|
@ -7,7 +7,7 @@ import core.Settings
|
|||
import security.Flood
|
||||
import lobby.{ Socket ⇒ LobbySocket }
|
||||
import socket.History
|
||||
import memo.MonoMemo
|
||||
import lila.common.memo.MonoMemo
|
||||
|
||||
import scalastic.elasticsearch
|
||||
import com.mongodb.casbah.MongoCollection
|
||||
|
|
26
common/ConfigSettings.scala
Normal file
26
common/ConfigSettings.scala
Normal file
|
@ -0,0 +1,26 @@
|
|||
package lila.common
|
||||
|
||||
import com.typesafe.config.{ Config, ConfigObject }
|
||||
import scalaz.{ Success, Failure }
|
||||
|
||||
abstract class ConfigSettings(config: Config) {
|
||||
|
||||
def this(configObject: ConfigObject) = this(configObject.toConfig)
|
||||
|
||||
protected def getInt(name: String) = config getInt name
|
||||
protected def getString(name: String) = config getString name
|
||||
protected def getMilliseconds(name: String) = config getMilliseconds name
|
||||
|
||||
protected def millis(name: String): Int = getMilliseconds(name).toInt
|
||||
|
||||
protected def seconds(name: String): Int = millis(name) / 1000
|
||||
|
||||
protected implicit def validAny[A](a: A) = new {
|
||||
def valid(f: A ⇒ Valid[A]): A = f(a) match {
|
||||
case Success(a) ⇒ a
|
||||
case Failure(err) ⇒ throw new Invalid(err.shows)
|
||||
}
|
||||
}
|
||||
|
||||
private class Invalid(msg: String) extends Exception(msg)
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
package lila
|
||||
package common
|
||||
package lila.common
|
||||
|
||||
import play.api.data.Forms._
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
package lila
|
||||
package common
|
||||
package lila.common
|
||||
|
||||
import play.api.Play.current
|
||||
import play.api.libs.concurrent._
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
package lila
|
||||
package common
|
||||
package lila.common
|
||||
|
||||
import java.text.Normalizer
|
||||
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
name := "lila-common"
|
||||
|
||||
organization := "org.lichess"
|
||||
|
||||
scalaVersion := "2.10.0"
|
||||
|
||||
resolvers ++= Seq(
|
||||
"iliaz.com" at "http://scala.iliaz.com/",
|
||||
"sonatype" at "http://oss.sonatype.org/content/repositories/releases",
|
||||
"sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",
|
||||
"typesafe.com" at "http://repo.typesafe.com/typesafe/releases/"
|
||||
)
|
||||
|
||||
libraryDependencies ++= Seq(
|
||||
"org.scalaz" %% "scalaz-core" % "6.0.4",
|
||||
"com.github.ornicar" %% "scalalib" % "3.3",
|
||||
// "play" %% "play" % "2.1.0" % "provided",
|
||||
"joda-time" % "joda-time" % "2.1",
|
||||
"org.joda" % "joda-convert" % "1.2",
|
||||
"org.reactivemongo" %% "reactivemongo" % "0.8"
|
||||
)
|
|
@ -1,5 +1,4 @@
|
|||
package lila.app
|
||||
package memo
|
||||
package lila.common.memo
|
||||
|
||||
import akka.actor._
|
||||
import scala.concurrent.{ Future, Await }
|
|
@ -1,5 +1,4 @@
|
|||
package lila.app
|
||||
package memo
|
||||
package lila.common.memo
|
||||
|
||||
import scalaz.effects._
|
||||
import scala.collection.JavaConversions._
|
|
@ -1,5 +1,4 @@
|
|||
package lila.app
|
||||
package memo
|
||||
package lila.common.memo
|
||||
|
||||
import com.google.common.base.Function
|
||||
import com.google.common.cache._
|
|
@ -1,5 +1,4 @@
|
|||
package lila.app
|
||||
package memo
|
||||
package lila.common.memo
|
||||
|
||||
import scalaz.effects._
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
package lila
|
||||
|
||||
package object common extends lila.common.PackageObject {
|
||||
|
||||
}
|
||||
package object common extends common.PackageObject
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
package lila.app
|
||||
package mongodb
|
||||
package lila.db
|
||||
|
||||
import com.github.ornicar.paginator._
|
||||
import com.novus.salat.dao.DAO
|
|
@ -1,5 +1,4 @@
|
|||
package lila.app
|
||||
package mongodb
|
||||
package lila.db
|
||||
|
||||
import com.mongodb.casbah.MongoCollection
|
||||
import com.mongodb.casbah.Imports._
|
|
@ -1,5 +1,4 @@
|
|||
package lila.app
|
||||
package mongodb
|
||||
package lila.db
|
||||
|
||||
import reactivemongo.api._
|
||||
import reactivemongo.bson._
|
|
@ -1,5 +1,4 @@
|
|||
package lila.app
|
||||
package mongodb
|
||||
package lila.db
|
||||
|
||||
import play.api.libs.json._
|
||||
|
|
@ -1,10 +1,7 @@
|
|||
package lila.app
|
||||
package mongodb
|
||||
package lila.db
|
||||
|
||||
import reactivemongo.api._
|
||||
|
||||
import core.Settings
|
||||
|
||||
final class Mongo2Env(val db: DB[Collection], settings: Settings) {
|
||||
|
||||
import settings._
|
|
@ -1,19 +1,15 @@
|
|||
package lila.app
|
||||
package mongodb
|
||||
package lila.db
|
||||
|
||||
import com.mongodb.casbah.MongoConnection
|
||||
import com.mongodb.{ Mongo, MongoOptions, ServerAddress ⇒ MongoServer }
|
||||
|
||||
import core.Settings
|
||||
|
||||
final class MongoDbEnv(
|
||||
settings: Settings) {
|
||||
final class MongoDbEnv(settings: Settings) {
|
||||
|
||||
import settings._
|
||||
|
||||
def apply(coll: String) = connection(coll)
|
||||
|
||||
lazy val cache = new Cache(connection(CoreCollectionCache))
|
||||
// lazy val cache = new Cache(connection(CoreCollectionCache))
|
||||
|
||||
lazy val connection = MongoConnection(server, options)(MongoDbName)
|
||||
|
15
db/Settings.scala
Normal file
15
db/Settings.scala
Normal file
|
@ -0,0 +1,15 @@
|
|||
package lila.db
|
||||
|
||||
import lila.common.ConfigSettings
|
||||
import com.typesafe.config.Config
|
||||
|
||||
final class Settings(config: Config) extends ConfigSettings(config getObject "mongodb") {
|
||||
|
||||
val MongoHost = getString("host")
|
||||
val MongoPort = getInt("port")
|
||||
val MongoDbName = getString("dbName")
|
||||
val MongoConnectionsPerHost = getInt("connectionsPerHost")
|
||||
val MongoAutoConnectRetry = getBoolean("autoConnectRetry")
|
||||
val MongoConnectTimeout = millis("connectTimeout")
|
||||
val MongoBlockingThreads = getInt("threadsAllowedToBlockForConnectionMultiplier")
|
||||
}
|
3
db/package.scala
Normal file
3
db/package.scala
Normal file
|
@ -0,0 +1,3 @@
|
|||
package lila
|
||||
|
||||
package object db extends common.PackageObject
|
|
@ -44,7 +44,11 @@ trait Dependencies {
|
|||
object ApplicationBuild extends Build with Resolvers with Dependencies {
|
||||
|
||||
private val buildSettings = Defaults.defaultSettings ++ Seq(
|
||||
scalaVersion := "2.10.0",
|
||||
organization in ThisBuild := "org.lichess",
|
||||
scalaVersion in ThisBuild := "2.10.0",
|
||||
resolvers in ThisBuild ++= Seq(
|
||||
awesomepom, sgodbillon, iliaz, sonatype, sonatypeS,
|
||||
typesafe, t2v, guice, jgitMaven, christophs),
|
||||
scalacOptions := Seq(
|
||||
"-deprecation",
|
||||
"-unchecked",
|
||||
|
@ -52,11 +56,12 @@ object ApplicationBuild extends Build with Resolvers with Dependencies {
|
|||
"-language:_")
|
||||
)
|
||||
|
||||
lazy val lila = play.Project("lila", "3", Seq(
|
||||
lazy val lila = play.Project("lila", "4",
|
||||
settings = buildSettings ++ Seq(
|
||||
libraryDependencies := Seq(
|
||||
scalaz, scalalib, hasher, config, salat, guava, apache, scalaTime,
|
||||
paginator, paginatorSalat, csv, jgit, actuarius, scalastic, findbugs,
|
||||
reactivemongo, playReactivemongo
|
||||
), settings = buildSettings).settings(
|
||||
reactivemongo),
|
||||
templatesImport ++= Seq(
|
||||
"lila.app.game.{ DbGame, DbPlayer, Pov }",
|
||||
"lila.app.user.User",
|
||||
|
@ -64,24 +69,30 @@ object ApplicationBuild extends Build with Resolvers with Dependencies {
|
|||
"lila.app.templating.Environment._",
|
||||
"lila.app.ui",
|
||||
"lila.app.http.Context",
|
||||
"com.github.ornicar.paginator.Paginator"),
|
||||
resolvers ++= Seq(awesomepom, sgodbillon, iliaz, sonatype, sonatypeS, typesafe, t2v, guice, jgitMaven, christophs)
|
||||
) dependsOn (scalachess, common, game) aggregate (scalachess, common, game)
|
||||
"com.github.ornicar.paginator.Paginator")
|
||||
)) dependsOn (user) aggregate (scalachess, common, db, user)
|
||||
|
||||
lazy val common = project("common").settings(
|
||||
resolvers := Seq(iliaz, sonatype),
|
||||
libraryDependencies := Seq(scalaz, scalalib, jodaTime, jodaConvert, playProvided)
|
||||
libraryDependencies := Seq(scalaz, scalalib, jodaTime, jodaConvert, playProvided, guava,
|
||||
reactivemongo)
|
||||
)
|
||||
|
||||
lazy val user = project("user").settings(
|
||||
resolvers := Seq(iliaz, sonatype),
|
||||
libraryDependencies := Seq(scalaz, scalalib, jodaTime, jodaConvert, playProvided)
|
||||
) dependsOn (scalachess)
|
||||
lazy val db = project("db", Seq(common)).settings(
|
||||
libraryDependencies := Seq(scalaz, scalalib, playProvided, guava, salat, reactivemongo,
|
||||
paginator, paginatorSalat, playReactivemongo)
|
||||
)
|
||||
|
||||
lazy val user = project("user", Seq(scalachess, common, db)).settings(
|
||||
libraryDependencies := Seq(scalaz, scalalib, jodaTime, jodaConvert, playProvided, salat,
|
||||
paginator, paginatorSalat)
|
||||
)
|
||||
|
||||
lazy val scalachess = project("scalachess").settings(
|
||||
resolvers := Seq(iliaz, sonatype, awesomepom),
|
||||
libraryDependencies := Seq(scalaz, scalalib, hasher, jodaTime, jodaConvert)
|
||||
)
|
||||
|
||||
private def project(name: String) = Project(name, file(name), settings = buildSettings)
|
||||
private type DepType = sbt.ClasspathDep[sbt.ProjectReference]
|
||||
|
||||
private def project(name: String, deps: Seq[DepType] = Seq.empty) =
|
||||
Project(name, file(name), settings = buildSettings, dependencies = deps)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package lila.app
|
||||
package user
|
||||
package lila.user
|
||||
|
||||
import memo.ActorMemo
|
||||
import lila.common.memo.ActorMemo
|
||||
|
||||
import scala.concurrent.duration._
|
||||
import scala.collection.mutable
|
|
@ -1,11 +1,8 @@
|
|||
package lila.app
|
||||
package user
|
||||
package lila.user
|
||||
|
||||
import play.api.data._
|
||||
import play.api.data.Forms._
|
||||
|
||||
import ui.Theme
|
||||
|
||||
object DataForm {
|
||||
|
||||
val bio = Form(single(
|
|
@ -1,5 +1,4 @@
|
|||
package lila.app
|
||||
package user
|
||||
package lila.user
|
||||
|
||||
import scala.math.round
|
||||
import scalaz.effects._
|
|
@ -1,5 +1,4 @@
|
|||
package lila.app
|
||||
package user
|
||||
package lila.user
|
||||
|
||||
import com.mongodb.casbah.MongoCollection
|
||||
import com.mongodb.casbah.query.Imports._
|
|
@ -1,5 +1,4 @@
|
|||
package lila.app
|
||||
package user
|
||||
package lila.user
|
||||
|
||||
import com.github.ornicar.paginator._
|
||||
import com.mongodb.casbah.Imports.DBObject
|
14
user/Settings.scala
Normal file
14
user/Settings.scala
Normal file
|
@ -0,0 +1,14 @@
|
|||
package lila.user
|
||||
|
||||
import lila.common.ConfigSettings
|
||||
import com.typesafe.config.Config
|
||||
|
||||
final class Settings(config: Config) extends ConfigSettings(config getObject "user") {
|
||||
|
||||
val UserPaginatorMaxPerPage = getInt("paginator.max_per_page")
|
||||
val UserEloUpdaterFloor = getInt("elo_updater.floor")
|
||||
val UserCachedNbTtl = millis("cached.nb.ttl")
|
||||
val UserCollectionUser = getString("collection.user")
|
||||
val UserCollectionHistory = getString("collection.history")
|
||||
val UserCollectionConfig = getString("collection.config")
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
package lila.app
|
||||
package ui
|
||||
package lila.user
|
||||
|
||||
import scalaz.NonEmptyLists
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
package lila.app
|
||||
package user
|
||||
package lila.user
|
||||
|
||||
import com.novus.salat.annotations.Key
|
||||
import org.joda.time.DateTime
|
|
@ -1,5 +1,4 @@
|
|||
package lila.app
|
||||
package user
|
||||
package lila.user
|
||||
|
||||
import com.mongodb.casbah.MongoCollection
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
package lila.app
|
||||
package user
|
||||
package lila.user
|
||||
|
||||
import com.novus.salat._
|
||||
import com.novus.salat.dao._
|
|
@ -1,7 +1,6 @@
|
|||
package lila.app
|
||||
package user
|
||||
package lila.user
|
||||
|
||||
import memo.BooleanExpiryMemo
|
||||
import lila.common.memo.BooleanExpiryMemo
|
||||
|
||||
import scalaz.effects._
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
name := "lila-user"
|
||||
|
||||
organization := "org.lichess"
|
||||
|
||||
scalaVersion := "2.10.0"
|
||||
|
||||
resolvers ++= Seq(
|
||||
"iliaz.com" at "http://scala.iliaz.com/",
|
||||
"sonatype" at "http://oss.sonatype.org/content/repositories/releases",
|
||||
"sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",
|
||||
"typesafe.com" at "http://repo.typesafe.com/typesafe/releases/"
|
||||
)
|
||||
|
||||
libraryDependencies ++= Seq(
|
||||
"org.scalaz" %% "scalaz-core" % "6.0.4",
|
||||
"com.github.ornicar" %% "scalalib" % "3.3",
|
||||
// "play" %% "play" % "2.1.0" % "provided",
|
||||
"joda-time" % "joda-time" % "2.1",
|
||||
"org.joda" % "joda-convert" % "1.2",
|
||||
"org.reactivemongo" %% "reactivemongo" % "0.8"
|
||||
)
|
3
user/package.scala
Normal file
3
user/package.scala
Normal file
|
@ -0,0 +1,3 @@
|
|||
package lila
|
||||
|
||||
package object user extends lila.common.PackageObject
|
Loading…
Reference in a new issue