avrora v0.1.0-beta Avrora.Resolver View Source

Resolves schema names or global ID's to a specific schema files while keeping memory and registry storage up to date.

Link to this section Summary

Functions

Resolves schema be it's name and optionally version. A version could be provided by adding : and version number to the name (i.e io.confluent.Payment:5).

Link to this section Functions

Link to this function

resolve(id) View Source
resolve(integer()) :: {:ok, Avrora.Schema.t()} | {:error, term()}
resolve(String.t()) :: {:ok, Avrora.Schema.t()} | {:error, term()}

Resolves schema be it's name and optionally version. A version could be provided by adding : and version number to the name (i.e io.confluent.Payment:5).

In case if confluent schema registry url is configured, resolution will take a look there first and in case of failure try to read schema from the configured schemas folder.

After schema being resolved it will be stored in memory storage with key equal name and name:version. Also it will be added to the registry if it's configured.

Examples

...> {:ok, avro1} = Avrora.Resolver.resolve("io.confluent.Payment")
...> {:ok, avro2} = Avrora.Resolver.resolve("io.confluent.Payment:42")
...> avro1.version
42
...> avro2.version
42
...> avro1.ex_schema.schema.qualified_names
["io.confluent.Paymen"]
...> avro2.ex_schema.schema.qualified_names
["io.confluent.Paymen"]