Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snapshot Event Handler State #461

Open
marpo60 opened this issue Nov 9, 2021 · 1 comment
Open

Snapshot Event Handler State #461

marpo60 opened this issue Nov 9, 2021 · 1 comment

Comments

@marpo60
Copy link
Contributor

marpo60 commented Nov 9, 2021

Context

Event Handler State is provided in the init/1 callback and can be updated in each handle/2
https://hexdocs.pm/commanded/1.3.0/Commanded.Event.Handler.html#module-event-handler-state

This is pretty handy, but at this moment the state is ephemeral, which means that on server restart, there is a need to reconstruct the state.

It would be awesome if the EventHandler state could be persisted in the same fashion as the Process Manager state.

def init(%State{} = state) do
{:ok, state, {:continue, :fetch_state}}
end

:ok = persist_state(event_number, state)

If there is value in doing this I can start implementing this.

@slashdotdash
Copy link
Member

Yes, I agree this would be a useful opt-in feature for event handlers. A pull request would be very welcome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants