Re: [akka-user] Re: Snapshots

2017-01-08 Thread Richard Rodseth
I've implemented snapshotting every n events by checking if offset modulo n
== 0.
Also, to answer myself, the snapshot is a Protobuf object as well.


On Sun, Jan 8, 2017 at 5:14 PM, Tal Pressman  wrote:

> Still, I don't think you can get snapshots that were saved by the
> "original" persistent actor through the persistence query. It's fairly easy
> to check, though - just save a snapshot and see if you can read it from the
> query.
>
> In any case, what I meant is that instead of only saving the offset in the
> read-side, you could save the offset along with the accumulated state and
> handle that snapshot as part of the persistent actor's recovery (by
> handling SnapshotOffer). Note that saving the offsets (and snapshots) is
> just an optimization, and you don't have to save them after *every* handled
> event. You could save them every number of events, after a certain time
> interval (just make sure they are saved together, so the information
> contained in the snapshot is in sync with the offset).
>
> Tal
>
>
> On Thursday, January 5, 2017 at 4:21:36 PM UTC+2, rrodseth wrote:
>
>> I have a PersistentActor which is a read side projection that runs a
>> persistence-query stream. It's only state is an offset, a Long. Protobuf
>> serialization is used for persistence messages.
>>
>> I'm preparing to add snapshotting. The examples show a "snap" message
>> handled by calling saveSnapshot.
>>
>> Am I correct that I should make the internal state passed to
>> saveSnapshot() a Protobuf object as well?
>>
>> And when would "snap" (or case object SaveSnapShot) typically be sent?
>>
> --
> >> Read the docs: http://akka.io/docs/
> >> Check the FAQ: http://doc.akka.io/docs/akka/
> current/additional/faq.html
> >> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: Snapshots

2017-01-08 Thread Tal Pressman
Still, I don't think you can get snapshots that were saved by the 
"original" persistent actor through the persistence query. It's fairly easy 
to check, though - just save a snapshot and see if you can read it from the 
query.

In any case, what I meant is that instead of only saving the offset in the 
read-side, you could save the offset along with the accumulated state and 
handle that snapshot as part of the persistent actor's recovery (by 
handling SnapshotOffer). Note that saving the offsets (and snapshots) is 
just an optimization, and you don't have to save them after *every* handled 
event. You could save them every number of events, after a certain time 
interval (just make sure they are saved together, so the information 
contained in the snapshot is in sync with the offset).

Tal


On Thursday, January 5, 2017 at 4:21:36 PM UTC+2, rrodseth wrote:
>
> I have a PersistentActor which is a read side projection that runs a 
> persistence-query stream. It's only state is an offset, a Long. Protobuf 
> serialization is used for persistence messages.
>
> I'm preparing to add snapshotting. The examples show a "snap" message 
> handled by calling saveSnapshot.
>
> Am I correct that I should make the internal state passed to 
> saveSnapshot() a Protobuf object as well?
>
> And when would "snap" (or case object SaveSnapShot) typically be sent? 
>

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Re: Snapshots

2017-01-08 Thread Richard Rodseth
Sorry this wasn't more clear. I *am* saving the offset of a
persistence-query. I'm saving it in the persistent actor that issues the
query.

On Sun, Jan 8, 2017 at 9:48 AM, Tal Pressman  wrote:

> If I am not mistaken, persistence-query does not support snapshots so you
> would have to save the snapshot along with your offset, and then for
> recovery you should load it manually and restart the persistence-query from
> the saved offset.
>
> Tal
>
>
> On Thursday, January 5, 2017 at 4:21:36 PM UTC+2, rrodseth wrote:
>>
>> I have a PersistentActor which is a read side projection that runs a
>> persistence-query stream. It's only state is an offset, a Long. Protobuf
>> serialization is used for persistence messages.
>>
>> I'm preparing to add snapshotting. The examples show a "snap" message
>> handled by calling saveSnapshot.
>>
>> Am I correct that I should make the internal state passed to
>> saveSnapshot() a Protobuf object as well?
>>
>> And when would "snap" (or case object SaveSnapShot) typically be sent?
>>
> --
> >> Read the docs: http://akka.io/docs/
> >> Check the FAQ: http://doc.akka.io/docs/akka/
> current/additional/faq.html
> >> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: Snapshots

2017-01-07 Thread Tal Pressman
If I am not mistaken, persistence-query does not support snapshots so you 
would have to save the snapshot along with your offset, and then for 
recovery you should load it manually and restart the persistence-query from 
the saved offset.

Tal


On Thursday, January 5, 2017 at 4:21:36 PM UTC+2, rrodseth wrote:
>
> I have a PersistentActor which is a read side projection that runs a 
> persistence-query stream. It's only state is an offset, a Long. Protobuf 
> serialization is used for persistence messages.
>
> I'm preparing to add snapshotting. The examples show a "snap" message 
> handled by calling saveSnapshot.
>
> Am I correct that I should make the internal state passed to 
> saveSnapshot() a Protobuf object as well?
>
> And when would "snap" (or case object SaveSnapShot) typically be sent? 
>

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.