View Source Synq.MessageBuilder (synq v0.2.0)
This is the default message builder for Synq. It will send json_patch
messages for state updates. The Elixir terms are compared using the JSONDiff
library to create the
JSON patch. Because JSONDiff is not aware of any impls of the JSON Encoder protocol, the patch
may or may not match the JSON encoding in certain cases. Best effort has been made to handle common
cases such ecto schemas and DateTime. To gain further control over this process, you
may implement the Synq.Encoder
protocol which will allow you to define a pre-diff representation.
For a slower, but potentially more correct approach to the problem, there is a branch containing an alternate json diff implemenation in rust.
Summary
Types
@type version() :: non_neg_integer()
Functions
@spec new_state_message( new_state :: map(), version :: version(), opts :: keyword() ) :: message_tuple()
@spec update_state_message( old_state :: map(), new_state :: map(), version :: version(), opts :: keyword() ) :: message_tuple()