Skip to content

Commit

Permalink
docs: Start from snapshot for drone push projection
Browse files Browse the repository at this point in the history
  • Loading branch information
johanandren committed Oct 18, 2023
1 parent b708b15 commit 0317a89
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ akka {
}
}
}

// #startFromSnapshot
akka.persistence.r2dbc.query.start-from-snapshot.enabled = true
// #startFromSnapshot
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ akka {
}
}
}

akka.persistence.r2dbc.query.start-from-snapshot.enabled = true
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ object Drone {
.receiveSignal { case (_, PostStop) =>
telemetry.droneEntityPassivated()
}
// #startFromSnapshot
.snapshotWhen { (_, event, _) =>
event.isInstanceOf[CoarseGrainedLocationChanged]
}
// #startFromSnapshot
}

// #commandHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,15 @@ object DroneEvents {
EventProducerSettings(system),
// only push coarse grained coordinate changes
producerFilter = envelope =>
envelope.event.isInstanceOf[Drone.CoarseGrainedLocationChanged]),
envelope.event.isInstanceOf[Drone.CoarseGrainedLocationChanged])
// #startFromSnapshot
// start from latest drone snapshot and don't replay history
.withStartingFromSnapshots[
Drone.State,
Drone.CoarseGrainedLocationChanged](state =>
Drone.CoarseGrainedLocationChanged(
state.coarseGrainedCoordinates.get)),
// #startFromSnapshot
GrpcClientSettings.fromConfig("central-drone-control"))

def projectionForPartition(
Expand Down

0 comments on commit 0317a89

Please sign in to comment.