Avrogen.Avro.Schema.CodeGenerator protocol (avrogen v1.1.0)

Copy Markdown View Source

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

global()

@type global() :: %{required(String.t()) => Avrogen.Avro.Schema.t()}

parent_namespace()

@type parent_namespace() :: String.t() | nil

scoped_embedded_types()

@type scoped_embedded_types() :: boolean()

t()

@type t() :: term()

All the types that implement this protocol.

Functions

contains_pii?(value, global)

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

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

decode_function(value, function_name, global)

@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.

drop_pii(value, function_name, global)

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

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

elixir_type(value)

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

Returns the elixir type spec for this Avro schema type.

encode_function(value, function_name, global)

@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

external_dependencies(value)

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

Extract the external dependencies fro this schema.

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

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.

random_instance(value, range_opts, global)

@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.