-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PROTOTYPE] Add unnamed types support #115
base: master
Are you sure you want to change the base?
Conversation
e569fd4
to
fe58fab
Compare
|
||
assert encoded == "59B02128" | ||
end | ||
|
||
test "when payload is matching the Union schema and schema is resolvable" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Add decoding test!
9eba871
to
a07dd77
Compare
a07dd77
to
ca7842c
Compare
lib/avrora/schema/encoder.ex
Outdated
@@ -47,8 +52,8 @@ defmodule Avrora.Schema.Encoder do | |||
@doc """ | |||
An example of a reference lookup which returns empty JSON body | |||
""" | |||
@spec reference_lookup(String.t()) :: {:ok, String.t()} | {:error, term()} | |||
def reference_lookup(_), do: {:ok, ~s({})} | |||
@spec reference_lookup(String.t()) :: {:error, term()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This spec is not complete!
ca7842c
to
5c884cb
Compare
5c884cb
to
b7e2619
Compare
b7e2619
to
7340ef8
Compare
@@ -8,6 +8,7 @@ defmodule Avrora.Schema.Encoder do | |||
alias Avrora.Schema.ReferenceCollector | |||
|
|||
@type reference_lookup_fun :: (String.t() -> {:ok, String.t()} | {:error, term()}) | |||
@undefined_name :undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not much value
do: SchemaEncoder.from_json(body, &read_schema_file_by_name/1) | ||
with {:ok, schema_name} <- Name.parse(key), | ||
{:ok, body} <- read_schema_file_by_name(key) do | ||
SchemaEncoder.from_json(body, name: schema_name.name, reference_lookup_fun: &read_schema_file_by_name/1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a refactoring here, nested calls generate too much lookup table. Considering unnamed types, we need to overhaul how we store lookup tables and how we work with them.
Resolves #95
This PR will add support for unnamed types. All codecs are going to support it. The only new limitation comes from Registry storage.
To "name" an unnamed type, we need its subject name and to get it we send a request to endpoint
/schemas/ids/{id}/versions
which exists only starting Confluent Schema Registry version5.5.0
.TODO
io.confluent
namespace withio.acme
confluent
naming update into mainRegistrar
also works