Avrora.Utils.Registrar (avrora v0.18.1) View Source

Memory store-aware schema registration with extended functionality designed to be used in the intensive loops.

It gives you control over the name under which schema will be registered (i.e subject in Schema Registry) and allows you to enforce registration even if the schema exists.

Examples

defmodule Sample do
  alias Avrora.Utils.Registrar

  def loop do
    Enum.reduce_while(1..100, 0, fn x, acc ->
      if x < 100, do: {:cont, register("io.confluent.Payment")}, else: {:halt, acc}
    end)
  end

  defp register(schema_name), do: Registrar.register_schema_by_name(schema_name)
end

Link to this section Summary

Functions

Register schema in the Schema Registry.

Register schema from local schema file in the Schema Registry.

Link to this section Functions

Link to this function

register_schema(schema, opts \\ [])

View Source

Specs

register_schema(Avrora.Schema.t(), as: String.t(), force: boolean()) ::
  {:ok, Avrora.Schema.t()} | {:error, term()}

Register schema in the Schema Registry.

This function relies on a Memory store before taking action. The most complete schema name will be looked at the store, i.e if the schema contains version then full_name + version will be used in prior just a full_name.

Options

  • :as - the name which will be used to register schema (i.e subject).
  • :force - the flag enforcing registration when schema was found in the Memory store (false by default).

Examples

...> {:ok, schema} = Avrora.Resolver.resolve("io.confluent.Payment")
...> {:ok, schema} = Avrora.Utils.Registrar.register_schema(schema, as: "NewName", force: true)
...> schema.full_name
"io.confluent.Payment"
Link to this function

register_schema_by_name(name, opts \\ [])

View Source

Specs

register_schema_by_name(String.t(), as: String.t(), force: boolean()) ::
  {:ok, Avrora.Schema.t()} | {:error, term()}

Register schema from local schema file in the Schema Registry.

Schema name conventions inherited from Avrora.Storage.File.get/1. For extended documentation about registration process see register_schema/2.

Options

  • :as - the name which will be used to register schema (i.e subject).
  • :force - the flag enforcing registration when schema was found in the Memory store (false by default).

Examples

...> {:ok, schema} = Avrora.Utils.Registrar.register_schema_by_name("io.confluent.Payment", as: "NewName", force: true)
...> schema.full_name
"io.confluent.Payment"