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
798 stars 93 forks source link

ra_machine: Allow the `version/0` callback to return 0 #399

Closed dumbbell closed 6 months ago

dumbbell commented 8 months ago

Why

0 is now a valid value the version/0 callback can return. It has always been a valid value, but the callback couldn't return that.

This allows a Ra machine module to explicitly set the initial version, even though it is the default implicit one.

How

The assert_integer/1 function, renamed to assert_version/1 in the progress, now accepts 0 as a valid value.

The version/0 callback spec is improved to return the version() type.

The is_versioned/1 helper behavior changes: an unversioned Ra machine is a module which doesn't export the version/0 callback.