avrora v0.1.0-beta Avrora.Encoder View Source

Encodes and decodes avro messages created with or without extra Schema Registry version.

Link to this section Summary

Functions

Decodes given message with a schema eather loaded from the local file or from the configured schema registry.

Encodes given message with a schema eather loaded from the local file or from the configured schema registry.

Link to this section Functions

Link to this function

decode(payload, list) View Source
decode(binary(), keyword(String.t())) :: {:ok, map()} | {:error, term()}

Decodes given message with a schema eather loaded from the local file or from the configured schema registry.

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>>
...> Avrora.Encoder.decode(payload, schema_name: "io.confluent.Payment")
{:ok, %{"id" => "00000000-0000-0000-0000-000000000000", "amount" => 15.99}}
Link to this function

encode(payload, list) View Source
encode(map(), keyword(String.t())) :: {:ok, binary()} | {:error, term()}

Encodes given message with a schema eather loaded from the local file or from the configured schema registry.

Examples

...> payload = %{"id" => "00000000-0000-0000-0000-000000000000", "amount" => 15.99}
...> Avrora.Encoder.encode(payload, schema_name: "io.confluent.Payment")
{:ok, <<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>>}