View Source Avrogen.AvroModule behaviour (avrogen v0.8.5)

Behaviour for generated record modules.

Summary

Callbacks

The fully qualified avro name of this record type.

The name of the schema that defines the record represented by this module.

Turn a raw map from an erlavro decoding operation into (nested) structs as defined by the generated avro modules.

Whether embedded schemas should be scoped to the type they are defined in.

Turn a (nested) struct (as defined by the generated avro modules) into an intermediate map that can be passed to a suitable erlavro encoder.

Callbacks

@callback avro_fqn() :: String.t()

The fully qualified avro name of this record type.

@callback avro_schema_name() :: String.t()

The name of the schema that defines the record represented by this module.

@callback from_avro_map(map()) :: {:ok, map()} | {:error, any()}

Turn a raw map from an erlavro decoding operation into (nested) structs as defined by the generated avro modules.

Link to this callback

scope_embedded_types?()

View Source (optional)
@callback scope_embedded_types?() :: boolean()

Whether embedded schemas should be scoped to the type they are defined in.

For example, for the following schema

{
  "name": "Event",
  "namespace": "events",
  "type": "record",
  "fields": [
    {
      "name": "details",
      "type": {
        "name": "Subtype",
        "type": "record",
        "fields": [
          ...
        ]
      }
    }
  ]
}

If set to true the internal type would be called "Events.Event.Subtype", otherwise, it would be "Events.Subtype".

If not provided default to false

@callback to_avro_map(map()) :: map()

Turn a (nested) struct (as defined by the generated avro modules) into an intermediate map that can be passed to a suitable erlavro encoder.