Packages

Dynamically load config files into ETS tables.

Current section

Files

Jump to
file_config lib file_config junk.ex
Raw

lib/file_config/junk.ex

defmodule FileConfig.Junk do
@moduledoc false
# @spec decode_binary(:ets.tid, name, term, term) :: term
# defp decode_binary(tid, name, key, value) when is_binary(value) do
# if :jsx.is_json(value) do
# value = :jsx.decode(value, [{:labels, :atom}, :return_maps])
# # |> merge_defaults(name, value)
# true = :ets.insert(tid, {key, value})
# value
# else
# Logger.debug("Invalid binary JSON for table #{name} key #{key}")
# value
# end
# end
# defp decode_binary(_tid, _name, _key, value), do: value
# @spec parse_json(binary | term) :: term
# def parse_json(value) when is_binary(value) do
# :jsx.decode(value, [{:labels, :atom}, :return_maps])
# end
# def parse_json(value), do: value
# @spec merge_defaults(map, atom) :: map
# def merge_defaults(value, name) when is_map(value) do
# config = Application.get_env(@app, :bertconf, [])
# ns_config = config[:namespaces] || %{}
# defaults = ns_config[name] || %{}
# Map.merge(defaults, value)
# end
# def merge_defaults(_, value), do: value
# @spec read_tc(namespace, term) :: :undefined | {:ok, term}
# def read_tc(name_space, key) do
# Metrics.tc([:bertconf, :read, :duration], [name: name_space], :bertconf, :read, [name_space, key])
# end
end