Skip to content

Commit

Permalink
Major refactor (#21)
Browse files Browse the repository at this point in the history
- Remove akka
- Scala 3
- Traditional database setup
  • Loading branch information
Merlijn van Ittersum authored Aug 27, 2023
1 parent 555e070 commit 7fcef1c
Show file tree
Hide file tree
Showing 150 changed files with 5,924 additions and 5,041 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
- persist_to_workspace:
root: .
paths:
- web-server/target/scala-2.13/amony.jar
- web-server/target/scala-3.3.0/amony.jar

build_web_client:

Expand Down Expand Up @@ -160,8 +160,8 @@ jobs:
- checkout
- attach_workspace:
at: .
- run: mkdir -p server/web-server/target/scala-2.13
- run: mv web-server/target/scala-2.13/amony.jar server/web-server/target/scala-2.13
- run: mkdir -p server/web-server/target/scala-3.3.0
- run: mv web-server/target/scala-3.3.0/amony.jar server/web-server/target/scala-3.3.0
- run: mv build web-client
- my-gcp/build-and-publish:
image: "amony/app"
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
*.log

# project specific
videos/
/media/
server/solr-search/solr/amony_embedded/data/

# backend, java, scala
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN mkdir /usr/amony/videos

# copy files
COPY ./web-client/build /usr/amony/web-client
COPY ./server/web-server/target/scala-2.13/amony.jar /usr/amony
COPY ./server/web-server/target/scala-3.3.0/amony.jar /usr/amony
COPY ./server/web-server/src/main/resources/prod/application.conf /usr/amony

WORKDIR /usr/amony
Expand Down
1 change: 1 addition & 0 deletions server/.jvmopts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Xss6M
199 changes: 129 additions & 70 deletions server/build.sbt
Original file line number Diff line number Diff line change
@@ -1,65 +1,85 @@
import sbt.Keys.scalaVersion
//import sbt.Keys.scalaVersion
import sbtassembly.AssemblyPlugin.autoImport.assemblyMergeStrategy

// --- Dependencies


val excludeLog4j =
ExclusionRule("org.apache.logging.log4j", "log4j-slf4j-impl")

val akkaVersion = "2.6.19"
val akkaHttpVersion = "10.2.9"
val circeVersion = "0.14.1"

val akka = "com.typesafe.akka" %% "akka-actor-typed" % akkaVersion
val akkaPersistence = "com.typesafe.akka" %% "akka-persistence-typed" % akkaVersion
val akkaPersistenceJdbc = "com.lightbend.akka" %% "akka-persistence-jdbc" % "5.0.4" // no scala 3
val akkaStream = "com.typesafe.akka" %% "akka-stream" % akkaVersion
val akkaPersistenceQuery = "com.typesafe.akka" %% "akka-persistence-query" % akkaVersion
val akkaSerializationJackson = "com.typesafe.akka" %% "akka-serialization-jackson" % akkaVersion
val excludeLog4j = ExclusionRule("org.apache.logging.log4j", "log4j-slf4j-impl")
val excludeScalaJs = List(
ExclusionRule("org.scala-lang", "scala3-library_sjs"),
ExclusionRule("org.scala-lang", "scala3-library_sjs1_3"),
ExclusionRule("org.scala-js", "scalajs-library_2.13")
)

val akkaHttp = "com.typesafe.akka" %% "akka-http" % akkaHttpVersion // no scala 3
val akkaHttpCirce = "de.heikoseeberger" %% "akka-http-circe" % "1.39.2" // no scala 3
val akkaVersion = "2.7.0"
val akkaHttpVersion = "10.4.0"
val circeVersion = "0.14.5"

val circe = "io.circe" %% "circe-core" % circeVersion
val circeGeneric = "io.circe" %% "circe-generic" % circeVersion
val circeParser = "io.circe" %% "circe-parser" % circeVersion

val slick = "com.typesafe.slick" %% "slick" % "3.3.3"
val slick = "com.typesafe.slick" %% "slick" % "3.5.0-M4"
val slickHikariCp = "com.typesafe.slick" %% "slick-hikaricp" % "3.5.0-M4"
val scalaLikeJdbc = "org.scalikejdbc" %% "scalikejdbc" % "4.0.0"

val jwtCirce = "com.github.jwt-scala" %% "jwt-circe" % "9.0.5"
val slf4jApi = "org.slf4j" % "slf4j-api" % "1.7.30"
val scribeSlf4j = "com.outr" %% "scribe-slf4j" % "3.5.5"
val jwtCirce = "com.github.jwt-scala" %% "jwt-circe" % "9.2.0"
val slf4jApi = "org.slf4j" % "slf4j-api" % "2.0.5"
val scribeSlf4j = "com.outr" %% "scribe-slf4j" % "3.11.2"

val monixReactive = "io.monix" %% "monix-reactive" % "3.4.1"
//val monixReactive = "io.monix" %% "monix-reactive" % "3.4.1"

val scalaTest = "org.scalatest" %% "scalatest" % "3.2.12" % Test
val fs2Core = "co.fs2" %% "fs2-core" % "3.7.0"
val fs2Io = "co.fs2" %% "fs2-io" % "3.7.0"
val catsEffect = "org.typelevel" %% "cats-effect" % "3.4.11"

val scalaTest = "org.scalatest" %% "scalatest" % "3.2.15" % Test
val scalaTestCheck = "org.scalatestplus" %% "scalacheck-1-15" % "3.2.11.0" % Test

val hsqlDB = "org.hsqldb" % "hsqldb" % "2.6.1"
val flywayDbCore = "org.flywaydb" % "flyway-core" % "8.5.12"
val hsqlDB = "org.hsqldb" % "hsqldb" % "2.6.1"
val h2DB = "com.h2database" % "h2" % "2.1.214"
val flywayDbCore = "org.flywaydb" % "flyway-core" % "9.16.0"
val caffeine = "com.github.ben-manes.caffeine" % "caffeine" % "3.1.5"
val jacksonDatabind = "com.fasterxml.jackson.core" % "jackson-databind" % "2.15.1"

val pureConfig = "com.github.pureconfig" %% "pureconfig" % "0.17.1" // no scala 3
val pureConfigSquants = "com.github.pureconfig" %% "pureconfig-squants" % "0.17.1" // no scala 3
//val pureConfig = ("com.github.pureconfig" %% "pureconfig-core" % "0.17.4") cross CrossVersion.for3Use2_13 // no scala 3
val pureConfig = "com.github.pureconfig" %% "pureconfig-core" % "0.17.4"
//val pureConfigSquants = ("com.github.pureconfig" %% "pureconfig-squants" % "0.17.2") cross CrossVersion.for3Use2_13 // no scala 3
val typesafeConfig = "com.typesafe" % "config" % "1.4.2"

//val betterFiles = "com.github.pathikrit" %% "better-files" % "3.9.1"
val directoryWatcher = "io.methvin" % "directory-watcher" % "0.15.0"
//val directoryWatcher = "io.methvin" % "directory-watcher" % "0.15.0"
val solr = "org.apache.solr" % "solr-core" % "8.11.1" excludeAll(excludeLog4j)
val solrLangId = "org.apache.solr" % "solr-langid" % "8.11.1" excludeAll(excludeLog4j)

val levelDb = "org.iq80.leveldb" % "leveldb" % "0.12"
val levelDbJndiAll = "org.fusesource.leveldbjni" % "leveldbjni-all" % "1.8"
val scalaPbRuntimeGrcp = "com.thesamet.scalapb" %% "scalapb-runtime-grpc" % scalapb.compiler.Version.scalapbVersion
val scalaPbRuntimeProtobuf = "com.thesamet.scalapb" %% "scalapb-runtime" % scalapb.compiler.Version.scalapbVersion % "protobuf"
val scalaPbRuntime = "com.thesamet.scalapb" %% "scalapb-runtime" % scalapb.compiler.Version.scalapbVersion

val javaOpts = Nil

val http4sVersion = "1.0.0-M40"

// -- Shared options
val http4sEmberServer = "org.http4s" %% "http4s-ember-server" % http4sVersion
val http4sEmberClient = "org.http4s" %% "http4s-ember-client" % http4sVersion
val http4sDsl = "org.http4s" %% "http4s-dsl" % http4sVersion
val http4sCirce = "org.http4s" %% "http4s-circe" % http4sVersion

//val tapirCirce = "com.softwaremill.sttp.tapir" %% "tapir-json-circe" % "1.2.9"
//val tapir = "com.softwaremill.sttp.tapir" %% "tapir-core" % "1.2.9"
//val tarirHttp4s = "com.softwaremill.sttp.tapir" %% "tapir-http4s-server" % "1.2.9"

val javaOpts = Nil

// -- Shared options

val commonSettings = Seq(
organization := "nl.amony",
scalaVersion := "2.13.8"
scalaVersion := "3.3.0",
excludeDependencies ++= excludeScalaJs,
assembly / assemblyMergeStrategy := {
case path if path.endsWith(".proto") => MergeStrategy.discard
case x => (assembly / assemblyMergeStrategy).value.apply(x)
}
)

lazy val noPublishSettings = Seq(
Expand All @@ -68,6 +88,12 @@ lazy val noPublishSettings = Seq(
publishArtifact := false
)

def protobufSettings = Seq(
Compile / PB.targets := Seq(
scalapb.gen(flatPackage = true) -> (Compile / sourceManaged).value / "scalapb"
)
)

def module(name: String, mainClass: Boolean = false) = {
val project = sbt.Project.apply(name, file(name))
.settings(commonSettings: _*)
Expand All @@ -85,65 +111,108 @@ lazy val common =
.settings(
name := "amony-lib-common",
libraryDependencies ++= Seq(
akka,
akkaPersistence,
pureConfig,
scribeSlf4j,
scalaTest,
directoryWatcher
// directoryWatcher,
// slick,
catsEffect,
)
)

lazy val libFFMPeg =
module("lib-ffmpeg")
.dependsOn(common)
.settings(
name := "amony-lib-ffmpeg",
libraryDependencies ++= Seq(
scribeSlf4j,
fs2Core,
scalaTest,
circe,
circeGeneric,
circeParser,
)
)

lazy val libEventStore =
module("lib-eventstore")
.settings(
name := "amony-lib-eventstore",
libraryDependencies ++= Seq(
pureConfig,
scribeSlf4j,
fs2Core,
slick,
scalaTest,
scalaPbRuntime,
slickHikariCp % "test",
h2DB % "test"
)
)

lazy val identity =
module("identity")
.dependsOn(common)
.dependsOn(common, libEventStore)
.settings(protobufSettings)
.settings(
name := "amony-service-auth",
libraryDependencies ++= Seq(
// akka
akka, akkaPersistence, akkaHttp, jwtCirce, akkaHttpCirce,
circe, circeGeneric, pureConfig
jwtCirce,
circe, circeGeneric, pureConfig, slick,
scalaPbRuntimeGrcp, scalaPbRuntimeProtobuf,
http4sDsl, http4sCirce
)
)

lazy val media =
module("media")
.dependsOn(common)
lazy val resources =
module("resources")
.dependsOn(common, libFFMPeg, libEventStore)
.settings(protobufSettings)
.settings(
name := "amony-service-media",
name := "amony-service-resources",
libraryDependencies ++= Seq(
scribeSlf4j, akka, akkaPersistence, akkaHttp, akkaHttpCirce, circe, circeGeneric, monixReactive,
directoryWatcher,
scribeSlf4j,
circe, circeGeneric, http4sCirce,
scalaTest,
slick
slick, fs2Core, fs2Io, http4sDsl,
scalaPbRuntimeGrcp, scalaPbRuntimeProtobuf,
slickHikariCp % "test",
h2DB % "test"
)
)

lazy val searchApi =
lazy val searchService =
module("search-api")
.dependsOn(common, media)
.dependsOn(resources)
.settings(protobufSettings)
.settings(
name := "amony-service-search-api",
libraryDependencies ++= Seq(
// akka
akka, akkaPersistence, akkaPersistenceQuery, akkaHttp, akkaHttpCirce, circe, circeGeneric
)
scribeSlf4j,
circe, circeGeneric, jacksonDatabind,
http4sDsl, http4sCirce
),
// PB.includePaths in Compile ++= Seq(file("media/src/main/protobuf")),
// PB.includePaths in Compile += file("search-api/src/main/protobuf")
)

lazy val solrSearch =
module("solr-search")
.dependsOn(common, searchApi)
.dependsOn(common, searchService)
.settings(
name := "amony-service-search-solr",
libraryDependencies ++= Seq(
slf4jApi, scribeSlf4j,
akka, solr, solrLangId
solr, solrLangId
)
)

lazy val amonyServer =
module("web-server", mainClass = true)
.dependsOn(identity, media, searchApi)
.dependsOn(identity, resources, searchService)
.settings(
name := "amony-web-server",
reStart / javaOptions ++= javaOpts,
Expand All @@ -155,25 +224,15 @@ lazy val amonyServer =
slf4jApi, scribeSlf4j,

// config loading
typesafeConfig, pureConfig, pureConfigSquants,

// akka
akka, akkaStream,

// akka persistence
akkaPersistence,
akkaPersistenceQuery,
akkaSerializationJackson,
levelDb, levelDbJndiAll, hsqlDB, flywayDbCore, akkaPersistenceJdbc,

// akka http & json serialization
akkaHttp, akkaHttpCirce,
typesafeConfig, pureConfig,
flywayDbCore,
slickHikariCp, hsqlDB,
h2DB,
circe,
circeGeneric,
circeParser,

monixReactive,

fs2Core,
http4sEmberServer,
// test
scalaTest, scalaTestCheck
),
Expand All @@ -190,11 +249,11 @@ lazy val amonyServer =
}
)

lazy val root = project
lazy val amony = project
.in(file("."))
.settings(noPublishSettings)
.settings(
Global / cancelable := true,
)
.disablePlugins(RevolverPlugin)
.aggregate(common, identity, media, searchApi, solrSearch, amonyServer)
.aggregate(common, libEventStore, libFFMPeg, identity, searchService, solrSearch, amonyServer)
5 changes: 5 additions & 0 deletions server/common/src/main/scala/nl/amony/lib/EventId.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package nl.amony.lib;

public @interface EventId {
String id();
}

This file was deleted.

Loading

0 comments on commit 7fcef1c

Please sign in to comment.