Decoder hook ๐ช finnaly available
Initially, the decoder hook was done as a non-configurable no-op function due to clarity โ how much it will be used and will be at all?. Seems the time has come, thanks to the @LostKobrakai ๐
The very first use-case is tagging unions, check this out:
defmodule MyClient do
use Avrora.Client,
decoder_hook: &__MODULE__.hook/4
def hook(type, sub_name_or_index, data, decode_fun) do
tag_unions_hook = :avro_decoder_hooks.tag_unions()
tag_unions_hook.(type, sub_name_or_index, data, decode_fun)
end
endNow all the complex unions will be tagged and result will be passed to the "private" Avrora decoder hook. But there is no limit on what you can do with it, just don't forget to call at the end decode_fun.(data) ๐
Have fun ๐ ๐ช