Skip to content

New schema registration functionality

Compare
Choose a tag to compare
@Strech Strech released this 23 Jan 11:27
· 50 commits to master since this release

In this release, a new module responsible for schema registration arises. Welcome Avrora.Utils.Registrar. It's designed to be used in the client code because it's using Avrora.Storage.Memory to prevent performance issues.

It allows you to control the name your AVRO schemas will be registered at (i.esubject in Schema Registry).

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

In addition, a mix task for schema registration was refactored (#65) to use this new functionality and now supports a new argument --as which in combination with --name option allows you to change the subject.

$ mix avrora.reg.schema --name io.confluent.Payment --as MyCustomName
schema `io.confluent.Payment' will be registered as `MyCustomName'

Thanks a lot to @arttsu #62 💚