evoq_feedback behaviour (evoq v1.14.1)

View Source

Feedback behaviour for evoq.

Feedback is the response to a Hope. It carries the result of command execution at the responder side, enabling session-level consistency.

Success feedback contains the post-event aggregate state so the requester has immediate truth without querying remote read models.

Error feedback contains the reason for failure.

Naming convention: {hope}_feedback_v1

Required Callbacks

- feedback_type() -> binary() - from_result(Result) -> map() - to_result(Payload) -> {ok, term()} | {error, term()}

Optional Callbacks

- serialize(Payload) -> {ok, binary()} | {error, Reason} - deserialize(Binary) -> {ok, map()} | {error, Reason}

Summary

Functions

Default deserialization using OTP 27 json module.

Default serialization using OTP 27 json module.

Callbacks

deserialize/1

(optional)
-callback deserialize(Binary :: binary()) -> {ok, map()} | {error, Reason :: term()}.

feedback_type/0

-callback feedback_type() -> binary().

from_result/1

-callback from_result(Result :: {ok, State :: term()} | {error, Reason :: term()}) -> map().

serialize/1

(optional)
-callback serialize(Payload :: map()) -> {ok, binary()} | {error, Reason :: term()}.
Custom deserialization (defaults available via default_deserialize/1).

to_result/1

-callback to_result(Payload :: map()) -> {ok, State :: term()} | {error, Reason :: term()}.

Functions

default_deserialize(Binary)

-spec default_deserialize(binary()) -> {ok, map()} | {error, term()}.

Default deserialization using OTP 27 json module.

default_serialize(Payload)

-spec default_serialize(map()) -> {ok, binary()} | {error, term()}.

Default serialization using OTP 27 json module.