Skip to content

Commit

Permalink
Docs: clarify init/1 callback expectations for machine versions
Browse files Browse the repository at this point in the history
  • Loading branch information
kjnilsson committed Feb 21, 2024
1 parent fc394fc commit b90fc3d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions docs/internals/STATE_MACHINE_TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,18 @@ which_module(0) -> my_machine_v0.

```

This would ensure that any entries added to the log are applied against the active machine version
at the time they were added, leading to a deterministic outcome.
This would ensure that any entries added to the log are applied against the
active machine version at the time they were added, leading to a deterministic
outcome.

For smaller (but still breaking) changes that can be handled in the original
module it is also possible to switch based on the `machine_version` key included in the meta
data passed to `apply/3`.
module it is also possible to switch based on the `machine_version` key
included in the meta data passed to `apply/3`.

NB: when using the latter approach combined with state upgrades the `init/1`
callback needs to return the v0 version of the state to ensure the state upgrade
code works as expected. It is recommended that if large change to the state
record needs to be made to use the multiple modules approach.

### Runtime Behaviour

Expand Down

0 comments on commit b90fc3d

Please sign in to comment.