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

Return an error if a `call` is unsupported #449

Closed dumbbell closed 2 weeks ago

dumbbell commented 2 weeks ago

Why

Currently, if a call to a Ra server is unsupported, the Ra server will ignore the event and the call will eventually time out. This could happen when Ra servers sport different versions of Ra for instance.

It would be nicer if the Ra server would reply immediatly with an error to let the caller know about the actual problem.

How

The Ra server could use a reply effect in the catch-all clause, but that effect will crash the Ra server if the initial event is not a call (i.e. it doesn't have a From to reply to).

This patch introduces a new effect, maybe_reply, that has the same overall behavior as reply, but the lack of a From isn't fatal.

The returned error is:

{error, {unsupported_call, Call}}