diff --git a/README.md b/README.md
index c79edaf2..9e554361 100644
--- a/README.md
+++ b/README.md
@@ -89,8 +89,6 @@ defmodule MyClient do
registry_user_agent: "Avrora/0.25.0 Elixir",
schemas_path: "./priv/schemas",
registry_schemas_autoreg: false,
- convert_null_values: false,
- convert_map_to_proplist: false,
names_cache_ttl: :timer.minutes(5),
decoder_hook: &MyClient.decoder_hook/4
end
@@ -110,8 +108,6 @@ config :avrora,
registry_user_agent: "Avrora/0.24.2 Elixir", # optional: if you want to return previous behaviour, set it to `nil`
schemas_path: "./priv/schemas",
registry_schemas_autoreg: false, # optional: if you want manually register schemas
- convert_null_values: false, # optional: if you want to keep decoded `:null` values as is
- convert_map_to_proplist: false, # optional: if you want to restore the old behavior for decoding map-type
names_cache_ttl: :timer.minutes(5), # optional: if you want periodic disk reads
decoder_hook: &MyClient.decoder_hook/4 # optional: if you want to amend the data/result
```
@@ -122,8 +118,6 @@ config :avrora,
- `registry_user_agent`[v0.25] - HTTP `User-Agent` header for Schema Registry requests, default `Avrora/ Elixir`
- `schemas_path` - Base path for locally stored schema files, default `./priv/schemas`
- `registry_schemas_autoreg`[v0.13] - Flag for automatic schemas registration in the Schema Registry, default `true`
-- `convert_null_values`[v0.14] - Flag for automatic conversion of decoded `:null` values into `nil`, default `true`
-- `convert_map_to_proplist`[v0.15] restore old behaviour and confiugre decoding map-type to proplist, default `false`
- `names_cache_ttl`[v0.10] - Time in ms to cache schemas by name in memory, default `:infinity`
- `decoder_hook`[v0.24] - Function with arity 4 to amend data or result, default `fn _, _, data, fun -> fun.(data) end`
diff --git a/config/config.exs b/config/config.exs
index 8e1cc952..d3228498 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -6,7 +6,6 @@ config :avrora,
registry_auth: nil,
registry_user_agent: nil,
registry_schemas_autoreg: true,
- convert_null_values: true,
names_cache_ttl: :infinity
config :logger, :console, format: "$time $metadata[$level] $levelpad$message\n"
diff --git a/lib/avrora/avro_decoder_options.ex b/lib/avrora/avro_decoder_options.ex
index f141222a..9123faa4 100644
--- a/lib/avrora/avro_decoder_options.ex
+++ b/lib/avrora/avro_decoder_options.ex
@@ -6,36 +6,32 @@ defmodule Avrora.AvroDecoderOptions do
alias Avrora.Config
- @options %{
- encoding: :avro_binary,
- hook: &__MODULE__.__hook__/4,
- is_wrapped: true,
- map_type: :map,
- record_type: :map
- }
@null_type_name "null"
@doc """
A unified erlavro decoder options compatible for both binary and OCF decoders.
"""
def options do
- if convert_map_to_proplist(), do: %{@options | map_type: :proplist}, else: @options
+ %{
+ encoding: :avro_binary,
+ hook: &__MODULE__.__hook__/4,
+ is_wrapped: true,
+ map_type: :map,
+ record_type: :map
+ }
end
# NOTE: This is internal module function and should never be used directly
@doc false
def __hook__(type, sub_name_or_idx, data, decode_fun) do
- convert = convert_null_values()
decoder_hook = decoder_hook()
result = decoder_hook.(type, sub_name_or_idx, data, decode_fun)
- if convert == true && :avro.get_type_name(type) == @null_type_name,
+ if :avro.get_type_name(type) == @null_type_name,
do: {nil, data},
else: result
end
- defp convert_null_values, do: Config.self().convert_null_values()
- defp convert_map_to_proplist, do: Config.self().convert_map_to_proplist()
defp decoder_hook, do: Config.self().decoder_hook()
end
diff --git a/lib/avrora/client.ex b/lib/avrora/client.ex
index 5a45f307..dd81c5d8 100644
--- a/lib/avrora/client.ex
+++ b/lib/avrora/client.ex
@@ -113,8 +113,6 @@ defmodule Avrora.Client do
def registry_auth, do: get(@opts, :registry_auth, nil)
def registry_user_agent, do: get(@opts, :registry_user_agent, "Avrora/#{version()} Elixir")
def registry_schemas_autoreg, do: get(@opts, :registry_schemas_autoreg, true)
- def convert_null_values, do: get(@opts, :convert_null_values, true)
- def convert_map_to_proplist, do: get(@opts, :convert_map_to_proplist, false)
def names_cache_ttl, do: get(@opts, :names_cache_ttl, :infinity)
def decoder_hook, do: get(@opts, :decoder_hook, fn _, _, data, fun -> fun.(data) end)
def file_storage, do: unquote(:"Elixir.#{module}.Storage.File")
diff --git a/lib/avrora/config.ex b/lib/avrora/config.ex
index 8c120ed1..4e1478dc 100644
--- a/lib/avrora/config.ex
+++ b/lib/avrora/config.ex
@@ -10,8 +10,6 @@ defmodule Avrora.Config do
* `registry_auth` authentication settings for Schema Registry, default `nil`
* `registry_user_agent` HTTP `User-Agent` header for Schema Registry requests, default `Avrora/ Elixir`
* `registry_schemas_autoreg` automatically register schemas in Schema Registry, default `true`
- * `convert_null_values` convert `:null` values in the decoded message into `nil`, default `true`
- * `convert_map_to_proplist` bring back old behavior and configure decoding AVRO map-type as proplist, default `false`
* `names_cache_ttl` duration to cache global schema names millisecods, default `:infinity`
* `decoder_hook` function to amend decoded payload, default `fn _, _, data, fun -> fun.(data) end`
@@ -29,8 +27,6 @@ defmodule Avrora.Config do
@callback registry_auth :: tuple() | nil
@callback registry_user_agent :: String.t() | nil
@callback registry_schemas_autoreg :: boolean()
- @callback convert_null_values :: boolean()
- @callback convert_map_to_proplist :: boolean()
@callback names_cache_ttl :: integer() | atom()
@callback decoder_hook :: (any(), any(), any(), any() -> any())
@callback file_storage :: module()
@@ -59,12 +55,6 @@ defmodule Avrora.Config do
@doc false
def registry_schemas_autoreg, do: get_env(:registry_schemas_autoreg, true)
- @doc false
- def convert_null_values, do: get_env(:convert_null_values, true)
-
- @doc false
- def convert_map_to_proplist, do: get_env(:convert_map_to_proplist, false)
-
@doc false
def names_cache_ttl, do: get_env(:names_cache_ttl, :infinity)
diff --git a/test/avrora/codec/object_container_file_test.exs b/test/avrora/codec/object_container_file_test.exs
index 75ee4f97..b95d1339 100644
--- a/test/avrora/codec/object_container_file_test.exs
+++ b/test/avrora/codec/object_container_file_test.exs
@@ -77,11 +77,9 @@ defmodule Avrora.Codec.ObjectContainerFileTest do
end
test "when payload is a valid binary and null values must be as is" do
- stub(Avrora.ConfigMock, :convert_null_values, fn -> false end)
-
{:ok, decoded} = Codec.ObjectContainerFile.decode(null_value_message(), schema: null_value_schema())
- assert decoded == [%{"key" => "user-1", "value" => :null}]
+ assert decoded == [%{"key" => "user-1", "value" => nil}]
end
test "when payload is a valid binary and null values must be converted" do
@@ -90,14 +88,6 @@ defmodule Avrora.Codec.ObjectContainerFileTest do
assert decoded == [%{"key" => "user-1", "value" => nil}]
end
- test "when payload is a valid binary and map type must be decoded as proplist" do
- stub(Avrora.ConfigMock, :convert_map_to_proplist, fn -> true end)
-
- {:ok, decoded} = Codec.ObjectContainerFile.decode(map_message())
-
- assert decoded == [%{"map_field" => [{"key", "value"}]}]
- end
-
test "when payload is a valid binary and map type must be decoded as map" do
{:ok, decoded} = Codec.ObjectContainerFile.decode(map_message())
diff --git a/test/avrora/codec/plain_test.exs b/test/avrora/codec/plain_test.exs
index c35549d6..67670e4c 100644
--- a/test/avrora/codec/plain_test.exs
+++ b/test/avrora/codec/plain_test.exs
@@ -78,11 +78,9 @@ defmodule Avrora.Codec.PlainTest do
end
test "when payload is a valid binary and null values must be as is" do
- stub(Avrora.ConfigMock, :convert_null_values, fn -> false end)
-
{:ok, decoded} = Codec.Plain.decode(null_value_message(), schema: null_value_schema())
- assert decoded == %{"key" => "user-1", "value" => :null}
+ assert decoded == %{"key" => "user-1", "value" => nil}
end
test "when payload is a valid binary and null values must be converted" do
@@ -91,14 +89,6 @@ defmodule Avrora.Codec.PlainTest do
assert decoded == %{"key" => "user-1", "value" => nil}
end
- test "when payload is a valid binary and map type must be decoded as proplist" do
- stub(Avrora.ConfigMock, :convert_map_to_proplist, fn -> true end)
-
- {:ok, decoded} = Codec.Plain.decode(map_message(), schema: map_schema())
-
- assert decoded == %{"map_field" => [{"key", "value"}]}
- end
-
test "when payload is a valid binary and map type must be decoded as map" do
{:ok, decoded} = Codec.Plain.decode(map_message(), schema: map_schema())
diff --git a/test/support/config.ex b/test/support/config.ex
index 184431f3..0d7d8529 100644
--- a/test/support/config.ex
+++ b/test/support/config.ex
@@ -44,14 +44,10 @@ defmodule Support.Config do
@impl true
def registry_schemas_autoreg, do: true
@impl true
- def convert_null_values, do: true
- @impl true
def names_cache_ttl, do: :infinity
@impl true
def decoder_hook, do: fn _, _, data, fun -> fun.(data) end
@impl true
- def convert_map_to_proplist, do: false
- @impl true
def file_storage, do: Avrora.Storage.FileMock
@impl true
def memory_storage, do: Avrora.Storage.MemoryMock