Rohan Sircar
3 years ago
9 changed files with 127 additions and 107 deletions
-
31.github/workflows/ci.yaml
-
1.scalafix.conf
-
87build.sbt
-
2modules/test-common/src/main/scala/wow/doge/MonixBioSuite.scala
-
9project/plugins.sbt
-
35src/it/scala/wow/doge/http4sdemo/MonixBioSuite.scala
-
67src/main/resources/application.conf
-
1src/main/scala/wow/doge/http4sdemo/Migrate.scala
-
1src/test/scala/wow/doge/http4sdemo/LibraryControllerSpec.scala
@ -0,0 +1 @@ |
|||||
|
rules = [OrganizeImports] |
@ -1,16 +1,15 @@ |
|||||
// addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.14") |
// addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.14") |
||||
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1") |
|
||||
|
|
||||
// https://github.com/tototoshi/sbt-slick-codegen |
|
||||
libraryDependencies += "com.h2database" % "h2" % "1.4.196" |
libraryDependencies += "com.h2database" % "h2" % "1.4.196" |
||||
libraryDependencies += "org.postgresql" % "postgresql" % "42.2.18" |
libraryDependencies += "org.postgresql" % "postgresql" % "42.2.18" |
||||
|
|
||||
|
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1") |
||||
addSbtPlugin("com.github.tototoshi" % "sbt-slick-codegen" % "1.4.0") |
addSbtPlugin("com.github.tototoshi" % "sbt-slick-codegen" % "1.4.0") |
||||
// Database migration |
|
||||
// https://github.com/flyway/flyway-sbt |
|
||||
addSbtPlugin("io.github.davidmweber" % "flyway-sbt" % "7.4.0") |
addSbtPlugin("io.github.davidmweber" % "flyway-sbt" % "7.4.0") |
||||
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.23") |
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.23") |
||||
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.0") |
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.0") |
||||
|
|
||||
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1") |
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1") |
||||
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2") |
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2") |
||||
|
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0") |
||||
|
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") |
||||
|
addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.4.13") |
@ -1,35 +0,0 @@ |
|||||
package wow.doge.http4sdemo |
|
||||
|
|
||||
import cats.syntax.all._ |
|
||||
import io.odin.consoleLogger |
|
||||
import io.odin.fileLogger |
|
||||
import io.odin.syntax._ |
|
||||
import monix.bio.Task |
|
||||
import monix.execution.Scheduler |
|
||||
|
|
||||
import scala.concurrent.Future |
|
||||
import munit.TestOptions |
|
||||
import cats.effect.Resource |
|
||||
import io.odin.Logger |
|
||||
|
|
||||
trait MonixBioSuite extends munit.TaglessFinalSuite[Task] { |
|
||||
override protected def toFuture[A](f: Task[A]): Future[A] = { |
|
||||
implicit val s = Scheduler.global |
|
||||
f.runToFuture |
|
||||
} |
|
||||
|
|
||||
def loggerFixture(fileName: Option[String] = None)(implicit |
|
||||
enc: sourcecode.Enclosing |
|
||||
) = |
|
||||
ResourceFixture( |
|
||||
consoleLogger[Task]().withAsync() |+| fileLogger[Task]( |
|
||||
fileName.getOrElse(enc.value.split("#").head + ".log") |
|
||||
), |
|
||||
( |
|
||||
options: TestOptions, |
|
||||
value: Logger[Task] |
|
||||
) => Task(options.name), |
|
||||
(_: Logger[Task]) => Task.unit |
|
||||
) |
|
||||
|
|
||||
} |
|
@ -1,56 +1,35 @@ |
|||||
|
|
||||
myapp = { |
myapp = { |
||||
database = { |
database = { |
||||
driver = org.postgresql.Driver |
|
||||
# url = "jdbc:postgresql://localhost:5432/test_db" |
|
||||
dbHost = localhost |
|
||||
dbHost = ${?APP_DB_HOST} |
|
||||
dbPort = 5432 |
|
||||
dbPort = ${?APP_DB_PORT} |
|
||||
dbName = test_db |
|
||||
dbName = ${?APP_DB_NAME} |
|
||||
url = "jdbc:postgresql://"${myapp.database.dbHost}":"${myapp.database.dbPort}"/"${myapp.database.dbName} |
|
||||
user = "test_user" |
|
||||
password = "password" |
|
||||
|
|
||||
// The number of threads determines how many things you can *run* in parallel |
|
||||
// the number of connections determines you many things you can *keep in memory* at the same time |
|
||||
// on the database server. |
|
||||
// numThreads = (core_count (hyperthreading included)) |
|
||||
numThreads = 16 |
|
||||
|
|
||||
// queueSize = ((core_count * 2) + effective_spindle_count) |
|
||||
// on a MBP 13, this is 2 cores * 2 (hyperthreading not included) + 1 hard disk |
|
||||
queueSize = 1000 |
|
||||
|
|
||||
// https://blog.knoldus.com/2016/01/01/best-practices-for-using-slick-on-production/ |
|
||||
// make larger than numThreads + queueSize |
|
||||
maxConnections = 16 |
|
||||
|
|
||||
connectionTimeout = 5000 |
|
||||
validationTimeout = 5000 |
|
||||
|
|
||||
# connectionPool = disabled |
|
||||
keepAlive = true |
|
||||
|
|
||||
migrations-table = "flyway_schema_history" |
|
||||
|
|
||||
|
driver = org.postgresql.Driver |
||||
|
dbHost = localhost |
||||
|
dbHost = ${?APP_DB_HOST} |
||||
|
dbPort = 5432 |
||||
|
dbPort = ${?APP_DB_PORT} |
||||
|
dbName = test_db |
||||
|
dbName = ${?APP_DB_NAME} |
||||
|
url = "jdbc:postgresql://"${myapp.database.dbHost}":"${myapp.database.dbPort}"/"${myapp.database.dbName} |
||||
|
user = "test_user" |
||||
|
password = "password" |
||||
|
numThreads = 16 |
||||
|
queueSize = 1000 |
||||
|
maxConnections = 16 |
||||
|
connectionTimeout = 5000 |
||||
|
validationTimeout = 5000 |
||||
|
# connectionPool = disabled |
||||
|
keepAlive = true |
||||
|
migrations-table = "flyway_schema_history" |
||||
migrations-locations = [ |
migrations-locations = [ |
||||
# "classpath:example/jdbc" |
|
||||
"classpath:db/migration/default" |
"classpath:db/migration/default" |
||||
] |
] |
||||
}, |
}, |
||||
testDatabase = { |
testDatabase = { |
||||
driver = org.postgresql.Driver |
|
||||
user = "scala" |
|
||||
password = "scala" |
|
||||
|
|
||||
numThreads = 16 |
|
||||
|
|
||||
queueSize = 10 |
|
||||
|
|
||||
|
driver = org.postgresql.Driver |
||||
|
user = "scala" |
||||
|
password = "scala" |
||||
|
numThreads = 16 |
||||
|
queueSize = 10 |
||||
maxConnections = 36 |
maxConnections = 36 |
||||
|
|
||||
} |
} |
||||
} |
} |
||||
|
|
||||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue