Nact documentation is available in the following languages
Nact 문서는 다음 언어로 제공됩니다.

javascript docs JavaScript

reasonml docs ReasonML


Sometimes actors accumulate a lot of persisted events. This is problematic because it means that it can take a potentially long time for an actor to recover. For time-sensitive applictions, this would make nact an unsuitable proposition. Snapshotting is a way to skip replaying every single event. When a persistent actor starts up again, nact checks to see if there are any snapshots available in the snapshot store. Nact selects the latest snapshot. The snapshot contains the sequence number at which it was taken. The snapshot is passed as the initial state to the actor, and only the events which were persisted after the snapshot are replayed.

To modify the user contacts service to support snapshotting, we refactor the code to the following:

let createContactsService = (parent, userId) =>
    ~key="contacts" ++ userId,
    ~snapshotEvery=10 * messages,
    (state, (sender, msg), {persist}) => {
      /* Same function as before */
    (ctx) => {contacts: ContactIdMap.empty, seqNumber: 0}

Here we are using the optional argument snapshotEvery to instruct nact to take a snapshot every 10 messages.