Avrora.Codec.decode

You're seeing just the callback decode, go back to Avrora.Codec module for more information.

Specs

decode(payloadd :: binary()) ::
  {:ok, result :: map() | [map()]} | {:error, reason :: term()}

Decode a binary Avro message into the Elixir data.

Examples

...> payload = <<0, 0, 0, 0, 8, 72, 48, 48, 48, 48, 48, 48, 48, 48, 45,
48, 48, 48, 48, 45, 48, 48, 48, 48, 45, 48, 48, 48, 48, 45, 48, 48, 48,
48, 48, 48, 48, 48, 48, 48, 48, 48, 123, 20, 174, 71, 225, 250, 47, 64>>
...> Avrora.Codec.SchemaRegistry.decode(payload)
{:ok, %{"id" => "00000000-0000-0000-0000-000000000000", "amount" => 15.99}}
Link to this callback

decode(payload, options)

View Source

Specs

decode(payload :: binary(), options :: keyword(Avrora.Schema.t())) ::
  {:ok, result :: map() | [map()]} | {:error, reason :: term()}

Decode a binary Avro message into the Elixir data with given schema.

Examples

...> payload = <<72, 48, 48, 48, 48, 48, 48, 48, 48, 45, 48, 48, 48, 48,
45, 48, 48, 48, 48, 45, 48, 48, 48, 48, 45, 48, 48, 48, 48, 48, 48, 48,
48, 48, 48, 48, 48, 123, 20, 174, 71, 225, 250, 47, 64>>
...> {:ok, schema} = Avrora.Resolver.resolve("io.confluent.Payment")
...> Avrora.Codec.Plain.decode(payload, schema: schema)
{:ok, %{"id" => "00000000-0000-0000-0000-000000000000", "amount" => 15.99}}