classy_vote ¶This module implements a variation of 2-phase commit.
Important to note:
This API uses both synchronous and asynchronous methods of status and error reporting.
Both methods must be handled in all cases.
Note: when classy_vote:create/1 API returns {ok, _},
it doesn’t mean the commit has been completed.
{ok, _},
it means commit flow entered "persistent" path.
Persistent path continues even after restart of any involved site.
Because of that, it uses asynchronous method of status reporting
via callbacks passed in the options.
The coordinator is notified of the outcome via post_vote callback.
The participants are notified via their respective commit or rollback callbacks.
post_vote, commit or rollback callbacks throw an exception,
on_fail callback gets involved.
Such mechanism is used because classy doesn’t automatically retry any actions that failed on the persistent path:
there is a high risk that these actions will just keep failing repeatedly.
Instead, they are abandoned until the next node restart.
on_fail callback provides a mechanism to signal such failures back to the business logic.