Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Mark snapshot envelopes with snapshot source #469

Merged
merged 3 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import akka.persistence.query.typed.EventEnvelope
val SourceQuery = ""
val SourceBacktracking = "BT"
val SourcePubSub = "PS"
val SourceSnapshot = "SN"

def fromQuery(env: EventEnvelope[_]): Boolean =
env.source == SourceQuery
Expand All @@ -28,6 +29,9 @@ import akka.persistence.query.typed.EventEnvelope
def fromPubSub(env: EventEnvelope[_]): Boolean =
env.source == SourcePubSub

def fromSnapshot(env: EventEnvelope[_]): Boolean =
env.source == SourceSnapshot

def isFilteredEvent(env: Any): Boolean =
env match {
case e: EventEnvelope[_] => e.filtered
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ final class R2dbcReadJournal(system: ExtendedActorSystem, config: Config, cfgPat
row.entityType,
row.slice,
filtered = false,
source = "",
source = EnvelopeOrigin.SourceSnapshot,
tags = row.tags)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package akka.persistence.r2dbc.query

import java.time.Instant

import akka.Done
import akka.NotUsed
import akka.actor.testkit.typed.scaladsl.LogCapturing
Expand All @@ -20,6 +19,7 @@ import akka.persistence.r2dbc.TestActors.Persister.PersistWithAck
import akka.persistence.r2dbc.TestConfig
import akka.persistence.r2dbc.TestData
import akka.persistence.r2dbc.TestDbLifecycle
import akka.persistence.r2dbc.internal.EnvelopeOrigin
import akka.persistence.r2dbc.query.scaladsl.R2dbcReadJournal
import akka.persistence.typed.PersistenceId
import akka.stream.scaladsl.Source
Expand Down Expand Up @@ -124,7 +124,9 @@ class EventsByPersistenceIdStartingFromSnapshotSpec
.runWith(sinkProbe)
.request(21)

result.expectNext().event shouldBe expectedSnapshotEvent(17)
val evt17 = result.expectNext()
evt17.event shouldBe expectedSnapshotEvent(17)
EnvelopeOrigin.fromSnapshot(evt17) shouldBe true
for (i <- 18 to 20) {
result.expectNext().event shouldBe s"e-$i"
}
Expand Down