rabbitmq / ra

A Raft implementation for Erlang and Elixir that strives to be efficient and make it easier to use multiple Raft clusters in a single system.
Other
813 stars 96 forks source link

Add `ra_machine:snapshot_installed/4` callback to pass old state #467

Closed the-mikedavis closed 1 month ago

the-mikedavis commented 1 month ago

This adds an extended version of the existing Machine:snapshot_installed(SnapMeta, NewState) callback which adds parameters for the old state: the state of the machine before the snapshot was installed and also its version since the snapshot installation might cause a version bump.

Module:snapshot_installed(SnapMeta, OldMacVer, OldState, NewState)

This is meant for any machine that needs to diff the old and new states. For example Khepri needs this (see rabbitmq/khepri#290) to update its projections when either the projections change or any part of the tree which is covered by a projection's pattern.