types

package
v5.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2018 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

View Source
const UTIL_FILE = "primitive.go"

Variables

This section is empty.

Functions

func NewArrayField

func NewArrayField(itemType AvroType, definition map[string]interface{}) *arrayField

func NewBoolField

func NewBoolField(definition interface{}) *boolField

func NewBytesField

func NewBytesField(definition interface{}) *bytesField

func NewDoubleField

func NewDoubleField(definition interface{}) *doubleField

func NewFloatField

func NewFloatField(definition interface{}) *floatField

func NewIntField

func NewIntField(definition interface{}) *intField

func NewLongField

func NewLongField(definition interface{}) *longField

func NewMapField

func NewMapField(itemType AvroType, definition map[string]interface{}) *mapField

func NewNullField

func NewNullField(definition interface{}) *nullField

func NewStringField

func NewStringField(definition interface{}) *stringField

func NewUnionField

func NewUnionField(name string, itemType []AvroType, definition []interface{}) *unionField

Types

type AvroType

type AvroType interface {
	Name() string
	GoType() string

	// The name of the method which writes this field onto the wire
	SerializerMethod() string
	// The name of the method which reads this field off the wire
	DeserializerMethod() string

	// Add the imports and struct for the definition of this type to the generator.Package
	AddStruct(*generator.Package, bool) error
	// Add the imports, methods and structs required for the serializer to the generator.Package
	AddSerializer(*generator.Package)
	// Add the imports, methods and structs required for the deserializer to the generator.Package
	AddDeserializer(*generator.Package)

	// Attempt to resolve references to named structs, enums or fixed fields
	ResolveReferences(*Namespace) error

	Definition(scope map[QualifiedName]interface{}) (interface{}, error)
	DefaultValue(lvalue string, rvalue interface{}) (string, error)
}

type Constructable

type Constructable interface {
	ConstructorMethod() string
}

type Definition

type Definition interface {
	AvroName() QualifiedName
	Aliases() []QualifiedName

	// A user-friendly name that can be built into a Go string (for unions, mostly)
	Name() string

	GoType() string

	SerializerMethod() string
	DeserializerMethod() string

	// Add the imports and struct for the definition of this type to the generator.Package
	AddStruct(*generator.Package, bool) error
	AddSerializer(*generator.Package)
	AddDeserializer(*generator.Package)

	// Resolve references to user-defined types
	ResolveReferences(*Namespace) error

	// A JSON object defining this object, for writing the schema back out
	Definition(scope map[QualifiedName]interface{}) (interface{}, error)
	DefaultValue(lvalue string, rvalue interface{}) (string, error)
}

type EnumDefinition

type EnumDefinition struct {
	// contains filtered or unexported fields
}

func NewEnumDefinition

func NewEnumDefinition(name QualifiedName, aliases []QualifiedName, symbols []string, definition map[string]interface{}) *EnumDefinition

func (*EnumDefinition) AddDeserializer

func (e *EnumDefinition) AddDeserializer(p *generator.Package)

func (*EnumDefinition) AddSerializer

func (e *EnumDefinition) AddSerializer(p *generator.Package)

func (*EnumDefinition) AddStruct

func (e *EnumDefinition) AddStruct(p *generator.Package, _ bool) error

func (*EnumDefinition) Aliases

func (e *EnumDefinition) Aliases() []QualifiedName

func (*EnumDefinition) AvroName

func (e *EnumDefinition) AvroName() QualifiedName

func (*EnumDefinition) DefaultValue

func (s *EnumDefinition) DefaultValue(lvalue string, rvalue interface{}) (string, error)

func (*EnumDefinition) Definition

func (s *EnumDefinition) Definition(scope map[QualifiedName]interface{}) (interface{}, error)

func (*EnumDefinition) DeserializerMethod

func (e *EnumDefinition) DeserializerMethod() string

func (*EnumDefinition) GoType

func (e *EnumDefinition) GoType() string

func (*EnumDefinition) Name

func (e *EnumDefinition) Name() string

func (*EnumDefinition) ResolveReferences

func (s *EnumDefinition) ResolveReferences(n *Namespace) error

func (*EnumDefinition) SerializerMethod

func (e *EnumDefinition) SerializerMethod() string

type Field

type Field struct {
	// contains filtered or unexported fields
}

* The interface implemented by all Avro field types.

func NewField

func NewField(avroName string, avroType AvroType, defValue interface{}, hasDef bool, definition map[string]interface{}) *Field

func (*Field) Default

func (f *Field) Default() interface{}

func (*Field) Definition

func (f *Field) Definition(scope map[QualifiedName]interface{}) (map[string]interface{}, error)

func (*Field) GoName

func (f *Field) GoName() string

func (*Field) HasDefault

func (f *Field) HasDefault() bool

func (*Field) Name

func (f *Field) Name() string

func (*Field) Type

func (f *Field) Type() AvroType

type FixedDefinition

type FixedDefinition struct {
	// contains filtered or unexported fields
}

func NewFixedDefinition

func NewFixedDefinition(name QualifiedName, aliases []QualifiedName, sizeBytes int, definition map[string]interface{}) *FixedDefinition

func (*FixedDefinition) AddDeserializer

func (s *FixedDefinition) AddDeserializer(p *generator.Package)

func (*FixedDefinition) AddSerializer

func (s *FixedDefinition) AddSerializer(p *generator.Package)

func (*FixedDefinition) AddStruct

func (s *FixedDefinition) AddStruct(p *generator.Package, _ bool) error

func (*FixedDefinition) Aliases

func (s *FixedDefinition) Aliases() []QualifiedName

func (*FixedDefinition) AvroName

func (s *FixedDefinition) AvroName() QualifiedName

func (*FixedDefinition) DefaultValue

func (s *FixedDefinition) DefaultValue(lvalue string, rvalue interface{}) (string, error)

func (*FixedDefinition) Definition

func (s *FixedDefinition) Definition(scope map[QualifiedName]interface{}) (interface{}, error)

func (*FixedDefinition) DeserializerMethod

func (s *FixedDefinition) DeserializerMethod() string

func (*FixedDefinition) GoType

func (s *FixedDefinition) GoType() string

func (*FixedDefinition) Name

func (s *FixedDefinition) Name() string

func (*FixedDefinition) ResolveReferences

func (s *FixedDefinition) ResolveReferences(n *Namespace) error

func (*FixedDefinition) SerializerMethod

func (s *FixedDefinition) SerializerMethod() string

type Namespace

type Namespace struct {
	Definitions map[QualifiedName]Definition
	Schemas     []Schema
	ShortUnions bool
}

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

func NewNamespace

func NewNamespace(shortUnions bool) *Namespace

func (*Namespace) AddToPackage

func (namespace *Namespace) AddToPackage(p *generator.Package, headerComment string, containers bool) error

func (*Namespace) RegisterDefinition

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

Add 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) (AvroType, error)

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

type QualifiedName

type QualifiedName struct {
	Namespace string
	Name      string
}

An Avro qualified name, which includes an optional namespace and the type name.

func ParseAvroName

func ParseAvroName(enclosing, name string) QualifiedName

Parse 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

func (QualifiedName) String

func (q QualifiedName) String() string

type RecordDefinition

type RecordDefinition struct {
	// contains filtered or unexported fields
}

func NewRecordDefinition

func NewRecordDefinition(name QualifiedName, aliases []QualifiedName, fields []*Field, metadata map[string]interface{}) *RecordDefinition

func (*RecordDefinition) AddDeserializer

func (r *RecordDefinition) AddDeserializer(p *generator.Package)

func (*RecordDefinition) AddSerializer

func (r *RecordDefinition) AddSerializer(p *generator.Package)

func (*RecordDefinition) AddStruct

func (r *RecordDefinition) AddStruct(p *generator.Package, containers bool) error

func (*RecordDefinition) Aliases

func (r *RecordDefinition) Aliases() []QualifiedName

func (*RecordDefinition) AvroName

func (r *RecordDefinition) AvroName() QualifiedName

func (*RecordDefinition) ConstructorMethod

func (r *RecordDefinition) ConstructorMethod() string

func (*RecordDefinition) ConstructorMethodDef

func (r *RecordDefinition) ConstructorMethodDef() (string, error)

func (*RecordDefinition) DefaultValue

func (r *RecordDefinition) DefaultValue(lvalue string, rvalue interface{}) (string, error)

func (*RecordDefinition) Definition

func (r *RecordDefinition) Definition(scope map[QualifiedName]interface{}) (interface{}, error)

func (*RecordDefinition) DeserializerMethod

func (r *RecordDefinition) DeserializerMethod() string

func (*RecordDefinition) FieldByName

func (r *RecordDefinition) FieldByName(name string) *Field

func (*RecordDefinition) GoType

func (r *RecordDefinition) GoType() string

func (*RecordDefinition) Name

func (r *RecordDefinition) Name() string

func (*RecordDefinition) ResolveReferences

func (r *RecordDefinition) ResolveReferences(n *Namespace) error

func (*RecordDefinition) SerializerMethod

func (r *RecordDefinition) SerializerMethod() string

type Reference

type Reference struct {
	// contains filtered or unexported fields
}

func NewReference

func NewReference(typeName QualifiedName) *Reference

func (*Reference) AddDeserializer

func (s *Reference) AddDeserializer(p *generator.Package)

func (*Reference) AddSerializer

func (s *Reference) AddSerializer(p *generator.Package)

func (*Reference) AddStruct

func (s *Reference) AddStruct(p *generator.Package, containers bool) error

func (*Reference) DefaultValue

func (s *Reference) DefaultValue(lvalue string, rvalue interface{}) (string, error)

func (*Reference) Definition

func (s *Reference) Definition(scope map[QualifiedName]interface{}) (interface{}, error)

func (*Reference) DeserializerMethod

func (s *Reference) DeserializerMethod() string

func (*Reference) GoType

func (s *Reference) GoType() string

func (*Reference) Name

func (s *Reference) Name() string

func (*Reference) ResolveReferences

func (s *Reference) ResolveReferences(n *Namespace) error

func (*Reference) SerializerMethod

func (s *Reference) SerializerMethod() string

type RequiredMapKeyError

type RequiredMapKeyError struct {
	Key string
}

func NewRequiredMapKeyError

func NewRequiredMapKeyError(key string) *RequiredMapKeyError

func (*RequiredMapKeyError) Error

func (r *RequiredMapKeyError) Error() string

type Schema

type Schema struct {
	Root       AvroType
	JSONSchema []byte
}

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