RaftEx.Server.Effects (raft_ex v0.1.0)

View Source

Pure helpers for building and combining Raft effect lists.

Effects are accumulated in reverse order during log application for efficiency, then reversed once at the end. All functions in this module follow that convention unless documented otherwise.

Summary

Functions

Append a reply effect (or notification) to the accumulator based on the command's reply_mode.

Emit an {idx, term} acknowledgement for :after_log_append commands.

Emit an error reply to the command's from field (if present).

Prepend machine-emitted effects onto the accumulator.

Wrap a non-empty notifys map into a {:notify, map} effect prepended to prior. Returns prior unchanged when notifys is empty.

Functions

add_reply(arg1, reply, arg3, effects, notifys)

@spec add_reply(map(), term(), term(), list(), map()) :: {list(), map()}

Append a reply effect (or notification) to the accumulator based on the command's reply_mode.

Returns {effects, notifys} where notifys is a %{pid => [corr_data]} map of pending pipeline notifications.

after_log_append_reply(arg1, idx, term, effects)

@spec after_log_append_reply(tuple(), non_neg_integer(), non_neg_integer(), list()) ::
  list()

Emit an {idx, term} acknowledgement for :after_log_append commands.

append_error_reply(arg1, reason, effects)

@spec append_error_reply(tuple(), term(), list()) :: list()

Emit an error reply to the command's from field (if present).

append_machine_effects(app_effs, effs)

@spec append_machine_effects(
  RaftEx.Machine.effects() | RaftEx.Machine.effect(),
  list()
) :: list()

Prepend machine-emitted effects onto the accumulator.

make_notify_effects(notifys, prior)

@spec make_notify_effects(map(), list()) :: list()

Wrap a non-empty notifys map into a {:notify, map} effect prepended to prior. Returns prior unchanged when notifys is empty.