Avrora.Encoder.encode
You're seeing just the function
encode
, go back to Avrora.Encoder module for more information.
Specs
encode(map(), schema_name: String.t(), format: :guess | :registry | :ocf | :plain ) :: {:ok, binary()} | {:error, term()}
Encode message map in Avro format, loading schema from local file or Schema Registry.
The :format
argument controls output format:
:plain
- Just return Avro binary data, with no header or embedded schema:ocf
- Use [Object Container File]https://avro.apache.org/docs/1.8.1/spec.html#Object+Container+Files) format, embedding the full schema with the data:registry
- Write data with Confluent Schema Registry Wire Format, which prefixes the data with the schema id:guess
- Use:registry
if possible, otherwise use:ocf
(default)
Examples
...> payload = %{"id" => "00000000-0000-0000-0000-000000000000", "amount" => 15.99}
...> Avrora.Encoder.encode(payload, schema_name: "io.confluent.Payment", format: :plain)
{: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>>}