+per #15424 Added PersistentView, deprecated View

A PersistentView works the same way as View did previously, except:

* it requires an `peristenceId` (no default is provided)
* messages given to `receive` are NOT wrapped in Persistent()

akka-streams not touched, will update them afterwards on different branch

Also solves #15436 by making persistentId in PersistentView abstract.

(cherry picked from commit dcafaf788236fe6d018388dd55d5bf9650ded696)

Conflicts:
	akka-docs/rst/java/lambda-persistence.rst
	akka-docs/rst/java/persistence.rst
	akka-docs/rst/scala/persistence.rst
	akka-persistence/src/main/scala/akka/persistence/Persistent.scala
	akka-persistence/src/main/scala/akka/persistence/View.scala
This commit is contained in:
Konrad 'ktoso' Malawski 2014-06-24 16:57:33 +02:00 committed by Patrik Nordwall
parent 2203968adb
commit 3fd240384c
22 changed files with 847 additions and 192 deletions

View file

@ -24,11 +24,10 @@ object ViewExample extends App {
}
}
class ExampleView extends View {
class ExampleView extends PersistentView {
private var numReplicated = 0
override def persistenceId: String = "persistentActor-5"
override def viewId = "view-5"
def receive = {
@ -37,9 +36,11 @@ object ViewExample extends App {
case SnapshotOffer(metadata, snapshot: Int) =>
numReplicated = snapshot
println(s"view received snapshot offer ${snapshot} (metadata = ${metadata})")
case Persistent(payload, _) =>
case payload if isPersistent =>
numReplicated += 1
println(s"view received ${payload} (num replicated = ${numReplicated})")
println(s"view received persistent ${payload} (num replicated = ${numReplicated})")
case payload =>
println(s"view received not persitent ${payload}")
}
}