avrora v0.11.0 Avrora.Resolver 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 string name with optional version.

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

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()}

Resolve schema by string name with optional version.

Version can be provided by adding : and version number, e.g. io.confluent.Payment:5.

If the Schema Registry is configured (:registry_url), it will first try there, then local schemas folder (:schemas_path).

Stores schema in memory with key name and name:version and adds schema to registry if configured.

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"
Link to this function

resolve_any(ids)

View Source
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"