Skip to content

Commit

Permalink
fix: EventWriter snapshot event
Browse files Browse the repository at this point in the history
* The EventWriter.Write now takes a isSnapshotEvent parameter,
  which means that sequence number gaps before the snapshot will
  be filled with filtered event payloads
* The EventEnvelope.source is "SN" for snapshot events
* No dependency to akka-persistence-r2dbc from akka-projection-grpc so
  hardcoding source "SN" (can't use EnvelopeOrigin)
  • Loading branch information
patriknw committed Oct 25, 2023
1 parent 3f2903c commit 4ab19bf
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,23 @@ import akka.projection.grpc.internal.proto.EventConsumerServicePowerApi
import akka.stream.scaladsl.Source
import io.grpc.Status
import org.slf4j.LoggerFactory

import scala.concurrent.ExecutionContext
import scala.concurrent.Promise

import akka.persistence.query.typed.EventEnvelope

/**
* INTERNAL API
*/
@InternalApi
private[akka] object EventPusherConsumerServiceImpl {
// See akka.persistence.r2dbc.internal.EnvelopeOrigin, but we don't have a dependency
// to akka-persistence-r2dbc here
def fromSnapshot(env: EventEnvelope[_]): Boolean =
env.source == "SN"

}

/**
* INTERNAL API
*
Expand All @@ -40,6 +53,7 @@ private[akka] final class EventPusherConsumerServiceImpl(
preferProtobuf: ProtoAnySerialization.Prefer)(implicit system: ActorSystem[_])
extends EventConsumerServicePowerApi {

import EventPusherConsumerServiceImpl.fromSnapshot
import ProtobufProtocolConversions._

private val logger = LoggerFactory.getLogger(classOf[EventPusherConsumerServiceImpl])
Expand Down Expand Up @@ -134,6 +148,7 @@ private[akka] final class EventPusherConsumerServiceImpl(
transformedEventEnvelope.persistenceId,
transformedEventEnvelope.sequenceNr,
transformedEventEnvelope.eventOption.getOrElse(FilteredPayload),
isSnapshotEvent = fromSnapshot(transformedEventEnvelope),
transformedEventEnvelope.eventMetadata,
transformedEventEnvelope.tags,
_))(destination.eventProducerPushDestination.settings.journalWriteTimeout, system.scheduler)
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object Dependencies {
val AkkaProjectionVersionInDocs = "1.5"

object Versions {
val akka = sys.props.getOrElse("build.akka.version", "2.9.0-M3")
val akka = sys.props.getOrElse("build.akka.version", "2.9.0-M3+24-4e2bc5b5-SNAPSHOT")
val akkaPersistenceCassandra = "1.2.0-M1"
val akkaPersistenceJdbc = "5.3.0-M1"
val akkaPersistenceR2dbc = "1.2.0-M7"
Expand Down
2 changes: 1 addition & 1 deletion samples/grpc/iot-service-scala/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ run / javaOptions ++= sys.props
.fold(Seq.empty[String])(res => Seq(s"-Dconfig.resource=$res"))
Global / cancelable := false // ctrl-c

val AkkaVersion = "2.9.0-M3"
val AkkaVersion = "2.9.0-M3+24-4e2bc5b5-SNAPSHOT"
val AkkaHttpVersion = "10.6.0-M2"
val AkkaManagementVersion = "1.5.0-M1"
val AkkaPersistenceR2dbcVersion = "1.2.0-M7"
Expand Down
2 changes: 1 addition & 1 deletion samples/grpc/local-drone-control-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<akka.version>2.9.0-M3</akka.version>
<akka.version>2.9.0-M3+24-4e2bc5b5-SNAPSHOT</akka.version>
<akka-projection.version>1.5.0-M5</akka-projection.version>
<akka-persistence-r2dbc.version>1.2.0-M7</akka-persistence-r2dbc.version>
<akka-management.version>1.5.0-M1</akka-management.version>
Expand Down
2 changes: 1 addition & 1 deletion samples/grpc/local-drone-control-scala/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ run / javaOptions ++= sys.props
.fold(Seq.empty[String])(res => Seq(s"-Dconfig.resource=$res"))
Global / cancelable := false // ctrl-c

val AkkaVersion = "2.9.0-M3"
val AkkaVersion = "2.9.0-M3+24-4e2bc5b5-SNAPSHOT"
val AkkaHttpVersion = "10.6.0-M2"
val AkkaManagementVersion = "1.5.0-M1"
val AkkaPersistenceR2dbcVersion = "1.2.0-M7"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<akka.version>2.9.0-M3</akka.version>
<akka.version>2.9.0-M3+24-4e2bc5b5-SNAPSHOT</akka.version>
<akka-projection.version>1.5.0-M5</akka-projection.version>
<akka-persistence-r2dbc.version>1.2.0-M6</akka-persistence-r2dbc.version>
<akka-management.version>1.5.0-M1</akka-management.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ run / javaOptions ++= sys.props
.fold(Seq.empty[String])(res => Seq(s"-Dconfig.resource=$res"))
Global / cancelable := false // ctrl-c

val AkkaVersion = "2.9.0-M3"
val AkkaVersion = "2.9.0-M3+24-4e2bc5b5-SNAPSHOT"
val AkkaHttpVersion = "10.6.0-M2"
val AkkaManagementVersion = "1.5.0-M1"
val AkkaPersistenceR2dbcVersion = "1.2.0-M6"
Expand Down
2 changes: 1 addition & 1 deletion samples/grpc/shopping-analytics-service-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<akka.version>2.9.0-M3</akka.version>
<akka.version>2.9.0-M3+24-4e2bc5b5-SNAPSHOT</akka.version>
<akka-projection.version>1.5.0-M5</akka-projection.version>
<akka-persistence-r2dbc.version>1.2.0-M7</akka-persistence-r2dbc.version>
<akka-management.version>1.5.0-M1</akka-management.version>
Expand Down
2 changes: 1 addition & 1 deletion samples/grpc/shopping-analytics-service-scala/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ run / javaOptions ++= sys.props
.fold(Seq.empty[String])(res => Seq(s"-Dconfig.resource=$res"))
Global / cancelable := false // ctrl-c

val AkkaVersion = "2.9.0-M3"
val AkkaVersion = "2.9.0-M3+24-4e2bc5b5-SNAPSHOT"
val AkkaHttpVersion = "10.6.0-M2"
val AkkaManagementVersion = "1.5.0-M1"
val AkkaPersistenceR2dbcVersion = "1.2.0-M7"
Expand Down
2 changes: 1 addition & 1 deletion samples/grpc/shopping-cart-service-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<akka.version>2.9.0-M3</akka.version>
<akka.version>2.9.0-M3+24-4e2bc5b5-SNAPSHOT</akka.version>
<akka-projection.version>1.5.0-M5</akka-projection.version>
<akka-persistence-r2dbc.version>1.2.0-M7</akka-persistence-r2dbc.version>
<akka-management.version>1.5.0-M1</akka-management.version>
Expand Down
2 changes: 1 addition & 1 deletion samples/grpc/shopping-cart-service-scala/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ run / javaOptions ++= sys.props
.fold(Seq.empty[String])(res => Seq(s"-Dconfig.resource=$res"))
Global / cancelable := false // ctrl-c

val AkkaVersion = "2.9.0-M3"
val AkkaVersion = "2.9.0-M3+24-4e2bc5b5-SNAPSHOT"
val AkkaHttpVersion = "10.6.0-M2"
val AkkaManagementVersion = "1.5.0-M1"
val AkkaPersistenceR2dbcVersion = "1.2.0-M7"
Expand Down
2 changes: 1 addition & 1 deletion samples/replicated/shopping-cart-service-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<akka.version>2.9.0-M3</akka.version>
<akka.version>2.9.0-M3+24-4e2bc5b5-SNAPSHOT</akka.version>
<akka-projection.version>1.5.0-M5</akka-projection.version>
<akka-persistence-r2dbc.version>1.2.0-M7</akka-persistence-r2dbc.version>
<akka-management.version>1.5.0-M1</akka-management.version>
Expand Down
2 changes: 1 addition & 1 deletion samples/replicated/shopping-cart-service-scala/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ run / javaOptions ++= sys.props
.fold(Seq.empty[String])(res => Seq(s"-Dconfig.resource=$res"))
Global / cancelable := false // ctrl-c

val AkkaVersion = sys.props.getOrElse("akka.version", "2.9.0-M3")
val AkkaVersion = sys.props.getOrElse("akka.version", "2.9.0-M3+24-4e2bc5b5-SNAPSHOT")
val AkkaHttpVersion = "10.6.0-M2"
val AkkaManagementVersion = "1.5.0-M1"
val AkkaPersistenceR2dbcVersion = "1.2.0-M7"
Expand Down

0 comments on commit 4ab19bf

Please sign in to comment.