Schema definitions cache handling.
All the schema definitions are stored in an ETS table for quick access during validation. This module provides an interface for: 1) updating of schema definitions in runtime; 2) getting of a schema definition by a key. When an update is ordered, the update function checks a schema definition file timestamp and compares it to a timestamp for the same schema in thecache
,
so, it will never update a schema in the database if the definition file
was not updated.
error() = {error, error_reason()}
error_reason() = {database_error, Key::string(), schema_not_found | unknown_uri_scheme}
reason() = term()
store_fail() = {file:filename(), file:date_time(), reason()}
store_result() = ok | [store_fail()]
add/3 | Adds a schema definition Schema to the internal storage associated
with the key Key . |
add_path/3 | Add schema definitions from all the files from directory Dir , each
being validated by ValidationFun , and stored in the internal storage. |
add_uri/1 | Add a schema definition to the internal storage identified by a URI Key. |
delete/1 | Deletes a schema definition from the internal storage associated with,
or sourced with the key Key . |
load/1 | Loads a schema definition associated with, or sourced with the key Key
from the internal storage. |
load_all/0 | Loads all schemas in the internal storage. |
load_uri/1 | Loads a schema definition associated with, or sourced with the key Key
from the internal storage. |
add(Key::string(), Schema::jesse:json_term(), ValidationFun::fun((any()) -> boolean())) -> store_result()
Adds a schema definition Schema
to the internal storage associated
with the key Key
. It will overwrite an existing schema with the same key if
there is any.
add_path(Path::string(), ParseFun::fun((binary()) -> jesse:json_term()), ValidationFun::fun((any()) -> boolean())) -> store_result()
Add schema definitions from all the files from directory Dir
, each
being validated by ValidationFun
, and stored in the internal storage.
The file modification time will also be stored, to skip unnecessary updates.
Schema definitions are stored in the format that ParseFun
returns.
add_uri(Key::string()) -> store_result()
Add a schema definition to the internal storage identified by a URI Key. Supported URI schemes are file:, http: and https:. If this fails, an exception will be thrown.
delete(Key::string()) -> ok
Deletes a schema definition from the internal storage associated with,
or sourced with the key Key
.
load(Key::string()) -> jesse:json_term() | no_return()
Loads a schema definition associated with, or sourced with the key Key
from the internal storage. If there is no such key in the storage, an
exception will be thrown.
load_all() -> [tuple()]
Loads all schemas in the internal storage.
load_uri(Key::string()) -> jesse:json_term() | no_return()
Loads a schema definition associated with, or sourced with the key Key
from the internal storage. If there is no such key in the storage, it will
try to fetch and add one to the internal storage if the Key uses the file:,
http: or https: URI scheme. If this fails as well, an exception will be
thrown.
Generated by EDoc