View Source Avrogen.Avro.Schema.CodeGenerator protocol (avrogen v0.8.1)

Protocol defining how different types representing an Avro schema should contribute to the code generation process.

Summary

Types

t()

All the types that implement this protocol.

Functions

Returns whether this type contains any PII including any PII in nested types.

Returns the function responsible decoding the value from an avro map.

Returns the function for dropping the the PII values stored in this type.

Returns the elixir type spec for this Avro schema type.

Returns the function responsible for encoding the value to an avro map

Extract the external dependencies fro this schema.

Normalizes the schema by extracting all embedded schemas into global and returning the schema with the embedded types replaced with references to their global names.

Returns the snippet of code responsible for generating a random instance of this type.

Types

@type global() :: %{required(String.t()) => Avrogen.Avro.Schema.t()}
@type parent_namespace() :: String.t() | nil
Link to this type

scoped_embedded_types()

View Source
@type scoped_embedded_types() :: boolean()
@type t() :: term()

All the types that implement this protocol.

Functions

Link to this function

contains_pii?(value, global)

View Source
@spec contains_pii?(Avrogen.Avro.Schema.t(), global()) :: boolean()

Returns whether this type contains any PII including any PII in nested types.

Link to this function

decode_function(value, function_name, global)

View Source
@spec decode_function(Avrogen.Avro.Schema.t(), atom(), global()) :: Macro.t()

Returns the function responsible decoding the value from an avro map.

Note the returned function should have a return type as a result tuple.

Link to this function

drop_pii(value, function_name, global)

View Source
@spec drop_pii(Avrogen.Avro.Schema.t(), atom(), global()) :: Macro.t()

Returns the function for dropping the the PII values stored in this type.

@spec elixir_type(Avrogen.Avro.Schema.t()) :: Macro.t()

Returns the elixir type spec for this Avro schema type.

Link to this function

encode_function(value, function_name, global)

View Source
@spec encode_function(Avrogen.Avro.Schema.t(), atom(), global()) :: Macro.t()

Returns the function responsible for encoding the value to an avro map

This should return a function with an infallible return type

Link to this function

external_dependencies(value)

View Source
@spec external_dependencies(Avrogen.Avro.Schema.t()) :: [String.t()]

Extract the external dependencies fro this schema.

Link to this function

normalize(value, global, parent_namespace, scope_embedded_types \\ false)

View Source

Normalizes the schema by extracting all embedded schemas into global and returning the schema with the embedded types replaced with references to their global names.

Link to this function

random_instance(value, range_opts, global)

View Source
@spec random_instance(Avrogen.Avro.Schema.t(), Keyword.t(), global()) :: Macro.t()

Returns the snippet of code responsible for generating a random instance of this type.