Avrora.Resolver (avrora v0.18.1) View Source

Resolve schema name or global ID to a schema, keeping cache up to date.

Link to this section Summary

Functions

Resolve schema by integer ID or by a string name with optional version, then update memory storage.

Resolve schema, trying multiple methods. First tries integer id, then string name.

Link to this section Functions

Specs

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

Resolve schema by integer ID or by a string name with optional version, then update memory storage.

In case of an integer ID it stores schema in memory with ID key.

Examples

...> {:ok, schema} = Avrora.Resolver.resolve(1)
...> schema.full_name
"io.confluent.Payment"

In case of a string name it stores schema in memory with key name and name:version, also adds schema to the Schema Registry (if it's configured).

A version for the name can be provided by adding : with the version number, e.g. io.confluent.Payment:5. If the Schema Registry is configured (:registry_url), it will first try fetch there, then local schemas folder (:schemas_path).

Examples

...> {:ok, schema1} = Avrora.Resolver.resolve("io.confluent.Payment")
...> {:ok, schema2} = Avrora.Resolver.resolve("io.confluent.Payment:42")
...> schema1.version
42
...> schema2.version
42
...> schema1.full_name
"io.confluent.Payment"
...> schema.full_name
"io.confluent.Payment"

Specs

resolve_any([integer() | String.t(), ...]) ::
  {:ok, Avrora.Schema.t()} | {:error, term()}

Resolve schema, trying multiple methods. First tries integer id, then string name.

Examples

...> {:ok, schema} = Avrora.Resolver.resolve_any([1, "io.confluent.Payment"])
...> schema.full_name
"io.confluent.Payment"