avrora v0.7.1 Avrora.Schema View Source

Convenience wrapper struct for AvroEx.Schema and Confluent Schema Registry.

Link to this section Summary

Functions

Parse Avro schema JSON and convert to struct.

Convert struct to erlavro format and look up in avro_schema_store.

Link to this section Types

Link to this type

t()

View Source
t() :: %Avrora.Schema{
  full_name: String.t(),
  id: nil | integer(),
  json: String.t(),
  lookup_table: reference(),
  version: nil | integer()
}

Link to this section Functions

Link to this function

parse(payload)

View Source
parse(String.t()) :: {:ok, t()} | {:error, term()}
parse(t()) :: {:ok, term()} | {:error, term()}

Parse Avro schema JSON and convert to struct.

Examples

iex> json = ~s({"namespace":"io.confluent","type":"record","name":"Payment","fields":[{"name":"id","type":"string"},{"name":"amount","type":"double"}]})
iex> {:ok, schema} = Avrora.Schema.parse(json)
iex> schema.full_name
"io.confluent.Payment"

Convert struct to erlavro format and look up in avro_schema_store.

Examples

iex> json = ~s({"namespace":"io.confluent","type":"record","name":"Payment","fields":[{"name":"id","type":"string"},{"name":"amount","type":"double"}]})
iex> {:ok, schema} = Avrora.Schema.parse(json)
iex> {:ok, {type, _, _, _, _, _, full_name, _}} = Avrora.Schema.to_erlavro(schema)
iex> full_name
"io.confluent.Payment"
iex> type
:avro_record_type