Authors: Ilya Staheev (ilya.staheev@klarna.com).
Stores all types in the schema.
The module allows to access all types in uniform way by using their full names. After a type was successfully placed into the store all its name parts are resolved so that no further actions to work with names are needed.
When type is added to the store all its children named types are extracted and stored as separate types as well. Their placeholders in the original type are replaced by their full names. The types itself keep their full names in 'name' field and empty strings in 'namespace'.
Error will be thrown when name conflict is detected during type addition.array_type() = #avro_array_type{type = avro:type_or_name(), custom = [avro:custom_prop()]}
avro_type() = primitive_type() | array_type() | enum_type() | fixed_type() | map_type() | record_type() | union_type()
enum_type() = #avro_enum_type{name = avro:name(), namespace = avro:namespace(), aliases = [avro:name()], doc = avro:typedoc(), symbols = [avro:enum_symbol()], fullname = avro:fullname(), custom = [avro:custom_prop()]}
filename() = file:filename_all()
fixed_type() = #avro_fixed_type{name = avro:name(), namespace = avro:namespace(), aliases = [avro:name()], size = pos_integer(), fullname = avro:fullname(), custom = [avro:custom_prop()]}
map_type() = #avro_map_type{type = avro:type_or_name(), custom = [avro:custom_prop()]}
name_raw() = atom() | string() | binary()
option_key() = access | name | dict
options() = [option_key() | {option_key(), term()}]
primitive_type() = #avro_primitive_type{name = avro:name(), custom = [avro:custom_prop()]}
record_type() = #avro_record_type{name = avro:name(), namespace = avro:namespace(), doc = avro:typedoc(), aliases = [avro:name()], fields = [avro:record_field()], fullname = avro:fullname(), custom = [avro:custom_prop()]}
abstract datatype: store()
union_type() = #avro_union_type{id2type = avro_union:id2type(), name2id = avro_union:name2id()}
add_type/2 | Add named type into the schema store. |
add_type/3 | Add (maybe unnamed) type to schema store. |
close/1 | Delete the ets table. |
ensure_store/1 | To make dialyzer happy. |
get_all_types/1 | Get all schema types. |
import_file/2 | Import avro JSON file into schema store. |
import_files/2 | Import avro JSON files into schema store. |
import_schema_json/2 | Decode avro schema JSON into erlavro records. |
is_store/1 | Return true if the given arg is a schema store. |
lookup_type/2 | Lookup a type using its full name. |
new/0 | Equivalent to new([]). |
new/1 | Create a new ets table to store avro types. |
new/2 | Create a new schema store and improt the given schema JSON files. |
to_lookup_fun/1 | Make a schema lookup function from store. |
add_type(Type::avro_type(), Store::store()) -> store()
Add named type into the schema store. NOTE: the type is flattened before inserting into the schema store. i.e. named types nested in the given type are lifted up to root level.
add_type(AssignedName::undefined | name_raw(), Type0::avro_type(), Store::store()) -> store()
Add (maybe unnamed) type to schema store. If the type is unnamed, the assigned name is used. For named types, the assigned name works like an alias.
close(Store::store()) -> ok
Delete the ets table.
ensure_store(Store::atom() | integer() | reference() | {dict, dict:dict()}) -> store()
To make dialyzer happy.
get_all_types(Store::store()) -> [avro_type()]
Get all schema types
import_file(File::filename(), Store::store()) -> store()
Import avro JSON file into schema store. In case the schema is unnamed, the file basename is used as its lookup name. Extention ".avsc" or ".json" will be stripped, Otherwise the full file basename is used. e.g. "/path/to/com.klarna.test.x.avsc" to 'com.klarna.etst.x" "/path/to/com.klarna.test.x.json" to 'com.klarna.etst.x" "/path/to/com.klarna.test.x" to 'com.klarna.etst.x"
import_files(Files::[filename()], Store::store()) -> store()
Import avro JSON files into schema store.
Decode avro schema JSON into erlavro records. NOTE: Exception if the type is unnamed.
is_store(T::term()) -> boolean()
Return true if the given arg is a schema store.
lookup_type(FullName::name_raw(), Store::store()) -> {ok, avro_type()} | false
Lookup a type using its full name.
new() -> store()
Equivalent to new([]).
Create a new ets table to store avro types.
Options:
* {access, public|protected|private}
- has same meaning as access
mode in ets:new and defines what processes can have access to
* {name, atom()}
- used to create a named ets table.
* dict
- use dict as store backend, ignore access
and name
options
new(Options::[proplists:property()], Files::[filename()]) -> store()
Create a new schema store and improt the given schema JSON files.
to_lookup_fun(Store::store()) -> fun((name_raw()) -> avro_type())
Make a schema lookup function from store.
Generated by EDoc