Generating Serdes mapping Clojure <-> Avro.
The intentional API of this NS has three main features -
SchemaCoercion
, the intentional type registry (of which
#'+base-schema-type-registry+
is an example) and
#'avro-serde
.
avro-serde
is the primary entry point to this namespace for
users. It's a function of a schema-registry configuration, a schema
type registry, and a serde configuration to be instantiated.
The intent is that an end user will partial
the avro-serde
function with their schema registry details and desired type
registry, and use the partial
'd function as en entry in a registry
as used by jackdaw.serdes/serde
.
This allows serdes
and avro-serde
to be agnostic to application
or environment specific configuration details.
But what's this type registry?
Apache Avro "logical types" - a tool for annotating fields in an
avro record as having some complex interpretation beyond their
serialized format. The type-registry
for the purposes of the
avro-serde
function a mapping of addresses to functions which will
when invoked build and return a SchemaCoercion
instance.
When a Serde is instantiated, a stack of SchemaCoercion
coersion
helpers is built which will - given a simply deserialized Avro
record - walk its tree coercing its to Clojure types as defined by
the SchemaCoercion
helpers.
The SchemaCoercion
stack is built by statically inspecting the parsed
Avro schema, and using the type (if any) and potentially logical
type to select a handler in the type-registry
which will, given a
function with which to recurse and the schema of that node, build
and return a SchemaCoercion
handler.
This registry pattern is deliberately chosen so that Avro coercion
will be customizable by the user. As an example, the
+UUID-type-registry+
is included, which defines a mapping from two
different logical UUID refinements of the binary string type to an
appropriate handler.
A user who wanted to opt into these handlers could simply call
avro-serde
with
(merge +base-schema-type-registry+ +UUID-type-registry+)
Users are HIGHLY encouraged to use the +base-schema-type-registry+
as the base for their type registries, as it defines sane handlings
for all of Avro's fundamental types and most of its compounds.
Generating Serdes mapping Clojure <-> Avro. The intentional API of this NS has three main features - `SchemaCoercion`, the intentional type registry (of which `#'+base-schema-type-registry+` is an example) and `#'avro-serde`. `avro-serde` is the primary entry point to this namespace for users. It's a function of a schema-registry configuration, a schema type registry, and a serde configuration to be instantiated. The intent is that an end user will `partial` the `avro-serde` function with their schema registry details and desired type registry, and use the `partial`'d function as en entry in a registry as used by `jackdaw.serdes/serde`. This allows `serdes` and `avro-serde` to be agnostic to application or environment specific configuration details. But what's this type registry? Apache Avro "logical types" - a tool for annotating fields in an avro record as having some complex interpretation beyond their serialized format. The `type-registry` for the purposes of the `avro-serde` function a mapping of addresses to functions which will when invoked build and return a `SchemaCoercion` instance. When a Serde is instantiated, a stack of `SchemaCoercion` coersion helpers is built which will - given a simply deserialized Avro record - walk its tree coercing its to Clojure types as defined by the `SchemaCoercion` helpers. The `SchemaCoercion` stack is built by statically inspecting the parsed Avro schema, and using the type (if any) and potentially logical type to select a handler in the `type-registry` which will, given a function with which to recurse and the schema of that node, build and return a `SchemaCoercion` handler. This registry pattern is deliberately chosen so that Avro coercion will be customizable by the user. As an example, the `+UUID-type-registry+` is included, which defines a mapping from two different logical UUID refinements of the binary string type to an appropriate handler. A user who wanted to opt into these handlers could simply call `avro-serde` with `(merge +base-schema-type-registry+ +UUID-type-registry+)` Users are HIGHLY encouraged to use the `+base-schema-type-registry+` as the base for their type registries, as it defines sane handlings for all of Avro's fundamental types and most of its compounds.
Helpers for talking to one of Confluent's Avro schema registries.
Helpers for talking to one of Confluent's Avro schema registries.
Implements an EDN SerDes (Serializer/Deserializer).
Implements an EDN SerDes (Serializer/Deserializer).
Implements a JSON SerDes (Serializer/Deserializer).
Implements a JSON SerDes (Serializer/Deserializer).
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close