parser

package
v6.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseAvroName

func ParseAvroName(enclosing, name string) avro.QualifiedName

ParseAvroName parses a name according to the Avro spec:

  • If the name contains a dot ('.'), the last part is the name and the rest is the namespace
  • Otherwise, the enclosing namespace is used

Types

type Namespace

type Namespace struct {
	Definitions map[avro.QualifiedName]avro.Definition
	Roots       []avro.Definition
	ShortUnions bool
}

Namespace is a mapping of avro.QualifiedNames to their Definitions, used to resolve type lookups within a schema.

func NewNamespace

func NewNamespace(shortUnions bool) *Namespace

func (*Namespace) RegisterDefinition

func (n *Namespace) RegisterDefinition(d avro.Definition) error

RegisterDefinition adds a new type definition to the namespace. Returns an error if the type is already defined.

func (*Namespace) TypeForSchema

func (n *Namespace) TypeForSchema(schemaJson []byte) (avro.AvroType, error)

TypeForSchema accepts an Avro schema as a JSON string, decode it and return the AvroType defined at the top level:

  • a single record definition (JSON map)
  • a union of multiple types (JSON array)
  • an already-defined type (JSON string)

The Avro type defined at the top level and all the type definitions beneath it will also be added to this Namespace.

type RequiredMapKeyError

type RequiredMapKeyError struct {
	Key string
}

func NewRequiredMapKeyError

func NewRequiredMapKeyError(key string) *RequiredMapKeyError

func (*RequiredMapKeyError) Error

func (r *RequiredMapKeyError) Error() string

type SchemaError

type SchemaError struct {
	FieldName   string
	NestedError error
}

func NewSchemaError

func NewSchemaError(fieldName string, err error) *SchemaError

func (*SchemaError) Error

func (s *SchemaError) Error() string

type WrongMapValueTypeError

type WrongMapValueTypeError struct {
	Key          string
	ExpectedType string
	ActualValue  interface{}
}

func NewWrongMapValueTypeError

func NewWrongMapValueTypeError(key, expectedType string, actualValue interface{}) *WrongMapValueTypeError

func (*WrongMapValueTypeError) Error

func (w *WrongMapValueTypeError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL