Skip to content

Commit

Permalink
try to support scala3 with slick
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning committed Jun 11, 2024
1 parent bb4e88a commit bef8153
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ lazy val slick =
Project(id = "slick", base = file("slick"))
.configs(IntegrationTest.extend(Test))
.enablePlugins(ReproducibleBuildsPlugin)
.settings(crossScalaVersions := Dependencies.Scala2Versions)
.settings(crossScalaVersions := Dependencies.Scala2And3Versions)
.settings(headerSettings(IntegrationTest))
.settings(Defaults.itSettings)
.settings(Dependencies.slick)
Expand Down
2 changes: 1 addition & 1 deletion project/PekkoCoreDependency.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ import com.github.pjfanning.pekkobuild.PekkoDependency
object PekkoCoreDependency extends PekkoDependency {
override val checkProject: String = "pekko-cluster-sharding-typed"
override val module: Option[String] = None
override val currentVersion: String = "1.0.2"
override val currentVersion: String = "1.1.0-M1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ object SlickProjection {

private def createOffsetStore[P <: JdbcProfile: ClassTag](databaseConfig: DatabaseConfig[P])(
implicit system: ActorSystem[_]) =
new SlickOffsetStore(system, databaseConfig.db, databaseConfig.profile, SlickSettings(system))
new SlickOffsetStore(system, databaseConfig, SlickSettings(system))
}

@ApiMayChange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,32 @@ import pekko.projection.jdbc.internal.MySQLDialect
import pekko.projection.jdbc.internal.OracleDialect
import pekko.projection.jdbc.internal.PostgresDialect
import pekko.util.Helpers.toRootLowerCase
import slick.basic.DatabaseConfig
import slick.jdbc.JdbcProfile

/**
* INTERNAL API
*/
@InternalApi private[projection] class SlickOffsetStore[P <: JdbcProfile](
system: ActorSystem[_],
val db: P#Backend#Database,
val profile: P,
val databaseConfig: DatabaseConfig[P],
slickSettings: SlickSettings,
clock: Clock) {

def this(system: ActorSystem[_], databaseConfig: DatabaseConfig[P], slickSettings: SlickSettings) =
this(system, databaseConfig, slickSettings, Clock.systemUTC())

import OffsetSerialization.MultipleOffsets
import OffsetSerialization.SingleOffset
import profile.api._
import databaseConfig.profile.api._

def this(system: ActorSystem[_], db: P#Backend#Database, profile: P, slickSettings: SlickSettings) =
this(system, db, profile, slickSettings, Clock.systemUTC())
private val db = databaseConfig.db

val (dialect, useLowerCase): (Dialect, Boolean) = {

val useLowerCase = slickSettings.useLowerCase

profile match {
databaseConfig.profile match {
case _: slick.jdbc.H2Profile =>
(
H2Dialect(slickSettings.schema, slickSettings.table, slickSettings.managementTable, useLowerCase),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private[projection] class SlickProjectionImpl[Offset, Envelope, P <: JdbcProfile
settings) {

implicit val executionContext: ExecutionContext = system.executionContext
override val logger: LoggingAdapter = Logging(system.classicSystem, this.getClass)
override val logger: LoggingAdapter = Logging(system.classicSystem, classOf[SlickInternalProjectionState])

override def readPaused(): Future[Boolean] =
offsetStore.readManagementState(projectionId).map(_.exists(_.paused))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ abstract class SlickOffsetStoreSpec(specConfig: SlickSpecConfig)
private val clock = new TestClock

private val offsetStore =
new SlickOffsetStore(system, dbConfig.db, dbConfig.profile, SlickSettings(slickConfig), clock)
new SlickOffsetStore(system, dbConfig, SlickSettings(slickConfig), clock)

override protected def beforeAll(): Unit = {
// create offset table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class SlickProjectionSpec

val dbConfig: DatabaseConfig[H2Profile] = DatabaseConfig.forConfig(SlickSettings.configPath, config)

val offsetStore = new SlickOffsetStore(system, dbConfig.db, dbConfig.profile, SlickSettings(system))
val offsetStore = new SlickOffsetStore(system, dbConfig, SlickSettings(system))

val projectionTestKit = ProjectionTestKit(system)

Expand Down

0 comments on commit bef8153

Please sign in to comment.