Skip to content

Commit

Permalink
remove unnecessary string interpolation (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning authored Nov 6, 2024
1 parent 3152ad4 commit f9742b7
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 49 deletions.
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ lazy val docs = project
"extref.pekko-docs.base_url" -> s"https://pekko.apache.org/docs/pekko/${Dependencies.PekkoVersionInDocs}/%s",
"extref.pekko-projection.base_url" -> s"https://pekko.apache.org/docs/pekko-projection/${Dependencies.PekkoProjectionVersionInDocs}/%s",
"extref.java-docs.base_url" -> "https://docs.oracle.com/en/java/javase/11/%s",
"scaladoc.scala.base_url" -> s"https://www.scala-lang.org/api/current/",
"scaladoc.scala.base_url" -> "https://www.scala-lang.org/api/current/",
"scaladoc.org.apache.pekko.persistence.r2dbc.base_url" ->
s"https://pekko.apache.org/api/pekko-persistence-r2dbc/${Dependencies.PekkoPersistenceR2dbcVersionInDocs}",
"scaladoc.org.apache.pekko.projection.r2dbc.base_url" ->
s"https://pekko.apache.org/api/pekko-persistence-r2dbc/${Dependencies.PekkoPersistenceR2dbcVersionInDocs}",
"scaladoc.org.apache.pekko.projection.base_url" ->
s"https://pekko.apache.org/api/pekko-projection/${Dependencies.PekkoProjectionVersionInDocs}",
"scaladoc.org.apache.pekko.base_url" -> s"https://pekko.apache.org/api/pekko/${Dependencies.PekkoVersionInDocs}",
"scaladoc.com.typesafe.config.base_url" -> s"https://lightbend.github.io/config/latest/api/"),
"scaladoc.com.typesafe.config.base_url" -> "https://lightbend.github.io/config/latest/api/"),
apidocRootPackage := "org.apache.pekko",
Compile / paradoxMarkdownToHtml / sourceGenerators += Def.taskDyn {
val targetFile = (Compile / paradox / sourceManaged).value / "license-report.md"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class EventsBySlicePerfSpec

private val query = PersistenceQuery(testKit.system).readJournalFor[R2dbcReadJournal](R2dbcReadJournal.Identifier)

s"EventsBySlices performance" should {
"EventsBySlices performance" should {

"retrieve from several slices" in {
// increase these properties for "real" testing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class EventsBySlicePubSubSpec
private val envB1 = createEnvelope(pidB, 1L, "b1")
private val envB2 = createEnvelope(pidB, 2L, "b2")

s"EventsBySlices pub-sub" should {
"EventsBySlices pub-sub" should {

"publish new events" in new Setup {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import pekko.projection.BySlicesSourceProvider
Future.failed(
new IllegalArgumentException(
s"Expected SourceProvider [${delegate.getClass.getName}] to implement " +
s"EventTimestampQuery when TimestampOffset is used."))
"EventTimestampQuery when TimestampOffset is used."))
}

override def loadEnvelope[Event](persistenceId: String, sequenceNr: Long): Future[EventEnvelope[Event]] =
Expand All @@ -86,6 +86,6 @@ import pekko.projection.BySlicesSourceProvider
Future.failed(
new IllegalArgumentException(
s"Expected SourceProvider [${delegate.getClass.getName}] to implement " +
s"EventTimestampQuery when LoadEventQuery is used."))
"EventTimestampQuery when LoadEventQuery is used."))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ private[projection] class R2dbcOffsetStore(
case Some(provider) => provider
case None =>
throw new IllegalArgumentException(
s"Expected BySlicesSourceProvider to be defined when TimestampOffset is used.")
"Expected BySlicesSourceProvider to be defined when TimestampOffset is used.")
}

private def timestampOf(persistenceId: String, sequenceNr: Long): Future[Option[Instant]] = {
Expand All @@ -276,7 +276,7 @@ private[projection] class R2dbcOffsetStore(
timestampQuery.timestampOf(persistenceId, sequenceNr).asScala.map(_.toScala)
case _ =>
throw new IllegalArgumentException(
s"Expected BySlicesSourceProvider to implement EventTimestampQuery when TimestampOffset is used.")
"Expected BySlicesSourceProvider to implement EventTimestampQuery when TimestampOffset is used.")
}
}

Expand Down Expand Up @@ -494,7 +494,7 @@ private[projection] class R2dbcOffsetStore(
if (slice < minSlice || slice > maxSlice)
throw new IllegalArgumentException(
s"This offset store [$projectionId] manages slices " +
s"[$minSlice - $maxSlice] but received slice [$slice] for persistenceId [${record.pid}]")
"[$minSlice - $maxSlice] but received slice [$slice] for persistenceId [${record.pid}]")

stmt
.bind(0, projectionId.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class R2dbcOffsetStoreSpec

"The R2dbcOffsetStore" must {

s"save and read offsets" in {
"save and read offsets" in {
val projectionId = genRandomProjectionId()
val offsetStore = createOffsetStore(projectionId)

Expand All @@ -83,39 +83,39 @@ class R2dbcOffsetStoreSpec
offset2.futureValue shouldBe Some(2L) // yep, saveOffset overwrites previous
}

s"save and retrieve offsets of type Long" in {
"save and retrieve offsets of type Long" in {
val projectionId = genRandomProjectionId()
val offsetStore = createOffsetStore(projectionId)
offsetStore.saveOffset(1L).futureValue
val offset = offsetStore.readOffset[Long]()
offset.futureValue shouldBe Some(1L)
}

s"save and retrieve offsets of type java.lang.Long" in {
"save and retrieve offsets of type java.lang.Long" in {
val projectionId = genRandomProjectionId()
val offsetStore = createOffsetStore(projectionId)
offsetStore.saveOffset(java.lang.Long.valueOf(1L)).futureValue
val offset = offsetStore.readOffset[java.lang.Long]()
offset.futureValue shouldBe Some(1L)
}

s"save and retrieve offsets of type Int" in {
"save and retrieve offsets of type Int" in {
val projectionId = genRandomProjectionId()
val offsetStore = createOffsetStore(projectionId)
offsetStore.saveOffset(1).futureValue
val offset = offsetStore.readOffset[Int]()
offset.futureValue shouldBe Some(1)
}

s"save and retrieve offsets of type java.lang.Integer" in {
"save and retrieve offsets of type java.lang.Integer" in {
val projectionId = genRandomProjectionId()
val offsetStore = createOffsetStore(projectionId)
offsetStore.saveOffset(java.lang.Integer.valueOf(1)).futureValue
val offset = offsetStore.readOffset[java.lang.Integer]()
offset.futureValue shouldBe Some(1)
}

s"save and retrieve offsets of type String" in {
"save and retrieve offsets of type String" in {
val projectionId = genRandomProjectionId()
val offsetStore = createOffsetStore(projectionId)
val randOffset = UUID.randomUUID().toString
Expand All @@ -124,7 +124,7 @@ class R2dbcOffsetStoreSpec
offset.futureValue shouldBe Some(randOffset)
}

s"save and retrieve offsets of type pekko.persistence.query.Sequence" in {
"save and retrieve offsets of type pekko.persistence.query.Sequence" in {
val projectionId = genRandomProjectionId()
val offsetStore = createOffsetStore(projectionId)
val seqOffset = Sequence(1L)
Expand All @@ -133,7 +133,7 @@ class R2dbcOffsetStoreSpec
offset.futureValue shouldBe Some(seqOffset)
}

s"save and retrieve offsets of type pekko.persistence.query.TimeBasedUUID" in {
"save and retrieve offsets of type pekko.persistence.query.TimeBasedUUID" in {
val projectionId = genRandomProjectionId()
val offsetStore = createOffsetStore(projectionId)

Expand All @@ -144,7 +144,7 @@ class R2dbcOffsetStoreSpec
offset.futureValue shouldBe Some(timeUuidOffset)
}

s"save and retrieve offsets of unknown custom serializable type" in {
"save and retrieve offsets of unknown custom serializable type" in {
val projectionId = genRandomProjectionId()
val offsetStore = createOffsetStore(projectionId)

Expand All @@ -154,7 +154,7 @@ class R2dbcOffsetStoreSpec
offset.futureValue shouldBe Some(customOffset)
}

s"save and retrieve MergeableOffset" in {
"save and retrieve MergeableOffset" in {
val projectionId = genRandomProjectionId()
val offsetStore = createOffsetStore(projectionId)
val origOffset = MergeableOffset(Map("abc" -> 1L, "def" -> 1L, "ghi" -> 1L))
Expand All @@ -163,7 +163,7 @@ class R2dbcOffsetStoreSpec
offset.futureValue shouldBe Some(origOffset)
}

s"add new offsets to MergeableOffset" in {
"add new offsets to MergeableOffset" in {
val projectionId = genRandomProjectionId()
val offsetStore = createOffsetStore(projectionId)

Expand All @@ -181,7 +181,7 @@ class R2dbcOffsetStoreSpec
offset2.futureValue shouldBe Some(updatedOffset)
}

s"update timestamp" in {
"update timestamp" in {
val projectionId = genRandomProjectionId()
val offsetStore = createOffsetStore(projectionId)

Expand All @@ -198,7 +198,7 @@ class R2dbcOffsetStoreSpec
instant3 shouldBe instant2
}

s"set offset" in {
"set offset" in {
val projectionId = genRandomProjectionId()
val offsetStore = createOffsetStore(projectionId)

Expand All @@ -209,7 +209,7 @@ class R2dbcOffsetStoreSpec
offsetStore.readOffset[Long]().futureValue shouldBe Some(2L)
}

s"clear offset" in {
"clear offset" in {
val projectionId = genRandomProjectionId()
val offsetStore = createOffsetStore(projectionId)

Expand All @@ -220,7 +220,7 @@ class R2dbcOffsetStoreSpec
offsetStore.readOffset[Long]().futureValue shouldBe None
}

s"read and save paused" in {
"read and save paused" in {
val projectionId = genRandomProjectionId()
val offsetStore = createOffsetStore(projectionId)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,33 +291,33 @@ class R2dbcTimestampOffsetProjectionSpec
val startTime = Instant.now()

Vector(
createEnvelope(pid1, 1, startTime, s"e1-1"),
createEnvelope(pid1, 2, startTime.plusMillis(1), s"e1-2"),
createEnvelope(pid2, 1, startTime.plusMillis(2), s"e2-1"),
createEnvelope(pid1, 3, startTime.plusMillis(4), s"e1-3"),
createEnvelope(pid1, 1, startTime, "e1-1"),
createEnvelope(pid1, 2, startTime.plusMillis(1), "e1-2"),
createEnvelope(pid2, 1, startTime.plusMillis(2), "e2-1"),
createEnvelope(pid1, 3, startTime.plusMillis(4), "e1-3"),
// pid1-3 is emitted before pid2-2 even though pid2-2 timestamp is earlier,
// from backtracking query previous events are emitted again, including the missing pid2-2
createEnvelope(pid1, 1, startTime, s"e1-1"),
createEnvelope(pid1, 2, startTime.plusMillis(1), s"e1-2"),
createEnvelope(pid2, 1, startTime.plusMillis(2), s"e2-1"),
createEnvelope(pid1, 1, startTime, "e1-1"),
createEnvelope(pid1, 2, startTime.plusMillis(1), "e1-2"),
createEnvelope(pid2, 1, startTime.plusMillis(2), "e2-1"),
// now it pid2-2 is included
createEnvelope(pid2, 2, startTime.plusMillis(3), s"e2-2"),
createEnvelope(pid1, 3, startTime.plusMillis(4), s"e1-3"),
createEnvelope(pid2, 2, startTime.plusMillis(3), "e2-2"),
createEnvelope(pid1, 3, startTime.plusMillis(4), "e1-3"),
// and then some normal again
createEnvelope(pid1, 4, startTime.plusMillis(5), s"e1-4"),
createEnvelope(pid2, 3, startTime.plusMillis(6), s"e2-3"))
createEnvelope(pid1, 4, startTime.plusMillis(5), "e1-4"),
createEnvelope(pid2, 3, startTime.plusMillis(6), "e2-3"))
}

def createEnvelopesUnknownSequenceNumbers(startTime: Instant, pid1: Pid, pid2: Pid): Vector[EventEnvelope[String]] = {
Vector(
createEnvelope(pid1, 1, startTime, s"e1-1"),
createEnvelope(pid1, 2, startTime.plusMillis(1), s"e1-2"),
createEnvelope(pid2, 1, startTime.plusMillis(2), s"e2-1"),
createEnvelope(pid1, 1, startTime, "e1-1"),
createEnvelope(pid1, 2, startTime.plusMillis(1), "e1-2"),
createEnvelope(pid2, 1, startTime.plusMillis(2), "e2-1"),
// pid2 seqNr 2 missing, will reject 3
createEnvelope(pid2, 3, startTime.plusMillis(4), s"e2-3"),
createEnvelope(pid1, 3, startTime.plusMillis(5), s"e1-3"),
createEnvelope(pid2, 3, startTime.plusMillis(4), "e2-3"),
createEnvelope(pid1, 3, startTime.plusMillis(5), "e1-3"),
// pid1 seqNr 4 missing, will reject 5
createEnvelope(pid1, 5, startTime.plusMillis(7), s"e1-5"))
createEnvelope(pid1, 5, startTime.plusMillis(7), "e1-5"))
}

def createEnvelopesBacktrackingUnknownSequenceNumbers(
Expand All @@ -326,14 +326,14 @@ class R2dbcTimestampOffsetProjectionSpec
pid2: Pid): Vector[EventEnvelope[String]] = {
Vector(
// may also contain some duplicates
createEnvelope(pid1, 2, startTime.plusMillis(1), s"e1-2"),
createEnvelope(pid2, 2, startTime.plusMillis(3), s"e2-2"),
createEnvelope(pid2, 3, startTime.plusMillis(4), s"e2-3"),
createEnvelope(pid1, 3, startTime.plusMillis(5), s"e1-3"),
createEnvelope(pid1, 4, startTime.plusMillis(6), s"e1-4"),
createEnvelope(pid1, 5, startTime.plusMillis(7), s"e1-5"),
createEnvelope(pid2, 4, startTime.plusMillis(8), s"e2-4"),
createEnvelope(pid1, 6, startTime.plusMillis(9), s"e1-6"))
createEnvelope(pid1, 2, startTime.plusMillis(1), "e1-2"),
createEnvelope(pid2, 2, startTime.plusMillis(3), "e2-2"),
createEnvelope(pid2, 3, startTime.plusMillis(4), "e2-3"),
createEnvelope(pid1, 3, startTime.plusMillis(5), "e1-3"),
createEnvelope(pid1, 4, startTime.plusMillis(6), "e1-4"),
createEnvelope(pid1, 5, startTime.plusMillis(7), "e1-5"),
createEnvelope(pid2, 4, startTime.plusMillis(8), "e2-4"),
createEnvelope(pid1, 6, startTime.plusMillis(9), "e1-6"))
}

def groupedHandler(probe: ActorRef[String]): R2dbcHandler[immutable.Seq[EventEnvelope[String]]] = {
Expand Down

0 comments on commit f9742b7

Please sign in to comment.