Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to use snapshots with PersistenceQuery

PersistentView has been deprecated in akka 2.4. The docs advise to switch to PersistenceQuery instead. However PersistenceQuery seems to be limited to the event journal only, without a capability to query the snapshot store.

Restoring a state from a large number of events takes some time, so the ability to use snapshots is important for me.

Is the deprecation a bit ahead of its time here? Should I continue to work with PersistentView or am I missing something? How do I work with snapshots using only PersistenceQuery?

Thank you

like image 423
kostja Avatar asked Aug 11 '16 09:08

kostja


People also ask

What is a persistent disk snapshot?

Snapshots incrementally back up data from your persistent disks. After you create a snapshot to capture the current state of the disk, you can use it to restore that data to a new disk.

What is the difference between image and snapshot in GCP?

A machine image can be used to backup multiple disks at a time. A persistent disk snapshot can only backup a single disk at a time.

Which is faster to create image or snapshot?

Snapshots: Reduced cost and faster to create than images.


1 Answers

One way to do it:

  • Make the Actor you use as the "PersistentView" extend a PersistentActor.
  • Store your PersistentQuery offset in the state of the PersistentActor and save snapshots regularly.
  • Initially set query offset to the earliest offset.
  • In the receiveRecover set the query offset to the offset stored in the PersistentActor snapshot.

Example: https://github.com/benniekrijger/todo-service/blob/master/src/main/scala/com/todos/repository/TodoRepositoryView.scala

like image 59
Bennie Krijger Avatar answered Sep 21 '22 06:09

Bennie Krijger