schema

package
v9.0.0-...-018aada Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

gogen-avro's internal representation of Avro schemas

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbstractType

type AbstractType interface {
	Name() string
	SimpleName() string
	GoType() string
	Definition(scope map[QualifiedName]interface{}) (interface{}, error)
	IsOptional() bool
}

type ArrayField

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

func NewArrayField

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

func (*ArrayField) Aliases

func (q *ArrayField) Aliases() []QualifiedName

func (*ArrayField) Children

func (s *ArrayField) Children() []AvroType

func (*ArrayField) DefaultValue

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

func (*ArrayField) Definition

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

func (*ArrayField) IsReadableBy

func (s *ArrayField) IsReadableBy(f AvroType, visited map[QualifiedName]interface{}) bool

func (*ArrayField) ItemConstructable

func (s *ArrayField) ItemConstructable() string

func (*ArrayField) ItemType

func (s *ArrayField) ItemType() AvroType

func (*ArrayField) QualifiedName

func (q *ArrayField) QualifiedName() QualifiedName

func (*ArrayField) Resolve

func (s *ArrayField) Resolve(ref Reference)

Resolve runtime data when item type is a reference, since its data cannot be always known at this array's creation time.

func (*ArrayField) WrapperType

func (s *ArrayField) WrapperType() string

type AvroType

type AvroType interface {
	AbstractType

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

	DefaultValue(lvalue string, rvalue interface{}) (string, error)

	WrapperType() string
	IsReadableBy(f AvroType, visited map[QualifiedName]interface{}) bool
}

type BoolField

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

func NewBoolField

func NewBoolField(definition interface{}) *BoolField

func (*BoolField) DefaultValue

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

func (*BoolField) IsReadableBy

func (s *BoolField) IsReadableBy(f AvroType, visited map[QualifiedName]interface{}) bool

func (*BoolField) SerializerMethod

func (p *BoolField) SerializerMethod() string

func (*BoolField) WrapperType

func (s *BoolField) WrapperType() string

type BytesField

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

func NewBytesField

func NewBytesField(definition interface{}) *BytesField

func (*BytesField) DefaultValue

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

func (*BytesField) IsReadableBy

func (s *BytesField) IsReadableBy(f AvroType, visited map[QualifiedName]interface{}) bool

func (*BytesField) SerializerMethod

func (p *BytesField) SerializerMethod() string

func (*BytesField) WrapperType

func (s *BytesField) WrapperType() string

type CompositeType

type CompositeType interface {
	Name() string
	Children() []AvroType
}

CompositeType must be implemented by any type containing children (array, record and union)

type Constructable

type Constructable interface {
	ConstructorMethod() string
}

type DoubleField

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

func NewDoubleField

func NewDoubleField(definition interface{}) *DoubleField

func (*DoubleField) DefaultValue

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

func (*DoubleField) IsReadableBy

func (s *DoubleField) IsReadableBy(f AvroType, visited map[QualifiedName]interface{}) bool

func (*DoubleField) SerializerMethod

func (p *DoubleField) SerializerMethod() string

func (*DoubleField) WrapperType

func (s *DoubleField) WrapperType() string

type EnumDefinition

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

func NewEnumDefinition

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

func (*EnumDefinition) Aliases

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

func (*EnumDefinition) DefaultValue

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

func (*EnumDefinition) Definition

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

func (*EnumDefinition) Doc

func (e *EnumDefinition) Doc() string

func (*EnumDefinition) IsReadableBy

func (s *EnumDefinition) IsReadableBy(d AvroType, visited map[QualifiedName]interface{}) bool

func (*EnumDefinition) QualifiedName

func (q *EnumDefinition) QualifiedName() QualifiedName

func (*EnumDefinition) SymbolName

func (e *EnumDefinition) SymbolName(symbol string) string

func (*EnumDefinition) Symbols

func (e *EnumDefinition) Symbols() []string

func (*EnumDefinition) WrapperType

func (s *EnumDefinition) WrapperType() string

type Field

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

func NewField

func NewField(name string, fieldType AvroType, aliases []string, doc string, definition map[string]interface{}, index int, fieldTags string) *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) Doc

func (f *Field) Doc() string

func (*Field) GoType

func (p *Field) GoType() string

func (*Field) HasDefault

func (f *Field) HasDefault() bool

func (*Field) Index

func (f *Field) Index() int

func (*Field) IsOptional

func (p *Field) IsOptional() bool

func (*Field) Name

func (p *Field) Name() string

func (*Field) SimpleName

func (p *Field) SimpleName() string

func (*Field) Tags

func (f *Field) Tags() string

Tags returns a field go struct tags if defined.

func (*Field) Type

func (f *Field) Type() AvroType

type FixedDefinition

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

func NewFixedDefinition

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

func (*FixedDefinition) Aliases

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

func (*FixedDefinition) DefaultValue

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

func (*FixedDefinition) Definition

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

func (*FixedDefinition) IsReadableBy

func (s *FixedDefinition) IsReadableBy(d AvroType, visited map[QualifiedName]interface{}) bool

func (*FixedDefinition) QualifiedName

func (q *FixedDefinition) QualifiedName() QualifiedName

func (*FixedDefinition) SizeBytes

func (s *FixedDefinition) SizeBytes() int

type FloatField

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

func NewFloatField

func NewFloatField(definition interface{}) *FloatField

func (*FloatField) DefaultValue

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

func (*FloatField) IsReadableBy

func (s *FloatField) IsReadableBy(f AvroType, visited map[QualifiedName]interface{}) bool

func (*FloatField) SerializerMethod

func (p *FloatField) SerializerMethod() string

func (*FloatField) WrapperType

func (s *FloatField) WrapperType() string

type IntField

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

func NewIntField

func NewIntField(definition interface{}) *IntField

func (*IntField) DefaultValue

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

func (*IntField) IsReadableBy

func (s *IntField) IsReadableBy(f AvroType, visited map[QualifiedName]interface{}) bool

func (*IntField) SerializerMethod

func (p *IntField) SerializerMethod() string

func (*IntField) WrapperType

func (s *IntField) WrapperType() string

type LongField

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

func NewLongField

func NewLongField(definition interface{}) *LongField

func (*LongField) DefaultValue

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

func (*LongField) IsReadableBy

func (s *LongField) IsReadableBy(f AvroType, visited map[QualifiedName]interface{}) bool

func (*LongField) SerializerMethod

func (p *LongField) SerializerMethod() string

func (*LongField) WrapperType

func (s *LongField) WrapperType() string

type MapField

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

func NewMapField

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

func (*MapField) Children

func (s *MapField) Children() []AvroType

func (*MapField) ConstructorMethod

func (s *MapField) ConstructorMethod() string

func (*MapField) DefaultValue

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

func (*MapField) Definition

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

func (*MapField) IsReadableBy

func (s *MapField) IsReadableBy(f AvroType, visited map[QualifiedName]interface{}) bool

func (*MapField) ItemConstructable

func (s *MapField) ItemConstructable() string

func (*MapField) ItemType

func (s *MapField) ItemType() AvroType

func (*MapField) SerializerMethod

func (p *MapField) SerializerMethod() string

func (*MapField) WrapperType

func (p *MapField) WrapperType() string

type NullField

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

func NewNullField

func NewNullField(definition interface{}) *NullField

func (*NullField) DefaultValue

func (p *NullField) DefaultValue(lvalue string, rvalue interface{}) (string, error)

func (*NullField) IsReadableBy

func (s *NullField) IsReadableBy(f AvroType, visited map[QualifiedName]interface{}) bool

func (*NullField) SerializerMethod

func (p *NullField) SerializerMethod() string

func (*NullField) WrapperType

func (p *NullField) WrapperType() string

type QualifiedAvroType

type QualifiedAvroType interface {
	AvroType
	QualifiedName() QualifiedName
	Aliases() []QualifiedName
}

type QualifiedName

type QualifiedName struct {
	Namespace string
	Name      string
}

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

func (QualifiedName) String

func (q QualifiedName) String() string

type RecordDefinition

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

func NewRecordDefinition

func NewRecordDefinition(qname QualifiedName, aliases []QualifiedName, fields []*Field, doc string, definition interface{}) *RecordDefinition

func (*RecordDefinition) Aliases

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

func (*RecordDefinition) Children

func (s *RecordDefinition) Children() []AvroType

func (*RecordDefinition) ConstructableForField

func (r *RecordDefinition) ConstructableForField(f *Field) string

func (*RecordDefinition) ConstructorMethod

func (r *RecordDefinition) ConstructorMethod() string

func (*RecordDefinition) DefaultForField

func (r *RecordDefinition) DefaultForField(f *Field) (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) Doc

func (s *RecordDefinition) Doc() string

func (*RecordDefinition) Fields

func (r *RecordDefinition) Fields() []*Field

func (*RecordDefinition) GetReaderField

func (r *RecordDefinition) GetReaderField(writerField *Field) *Field

func (*RecordDefinition) IsReadableBy

func (s *RecordDefinition) IsReadableBy(d AvroType, visited map[QualifiedName]interface{}) bool

func (*RecordDefinition) QualifiedName

func (q *RecordDefinition) QualifiedName() QualifiedName

func (*RecordDefinition) Schema

func (s *RecordDefinition) Schema() (string, error)

type Reference

type Reference struct {
	// contains filtered or unexported fields
}
  A named Reference to a user-defined type (fixed, enum, record). Just a wrapper with a name around a qnamed type.
  If a reference is created without a defined type, all parsing-time values are returned as invalid values.
  Once the reference gets assigned a type, it triggers its registered resolvers' Resolve(ref) method.
  This is commonly transparent for almost all types, but some other types depend on their children fields for
  defining their internal data, like Name and GoType.
  Examples of this are:
	- Arrays of base types defined as references: the resolver renames the array to its final name.
	- Union types with named-types' members: once all its children refs are triggered, the union gets renamed.

func NewReference

func NewReference(name QualifiedName, t QualifiedAvroType) *Reference

func (*Reference) AddResolver

func (r *Reference) AddResolver(resolver referenceResolver)

func (Reference) Aliases

func (r Reference) Aliases() []QualifiedName

func (Reference) Children

func (r Reference) Children() []AvroType

func (Reference) DefaultValue

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

func (Reference) Definition

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

func (Reference) GoType

func (r Reference) GoType() string

func (Reference) IsOptional

func (r Reference) IsOptional() bool

func (Reference) IsReadableBy

func (r Reference) IsReadableBy(f AvroType, visited map[QualifiedName]interface{}) bool

func (Reference) IsUntyped

func (r Reference) IsUntyped() bool

func (Reference) Name

func (r Reference) Name() string

func (Reference) QualifiedName

func (r Reference) QualifiedName() QualifiedName

func (Reference) RefName

func (r Reference) RefName() QualifiedName

func (Reference) RefType

func (r Reference) RefType() QualifiedAvroType

func (Reference) SerializerMethod

func (r Reference) SerializerMethod() string

The name of the method which writes this field onto the wire

func (*Reference) SetType

func (r *Reference) SetType(t QualifiedAvroType)

func (Reference) SimpleName

func (r Reference) SimpleName() string

func (Reference) WrapperType

func (r Reference) WrapperType() string

type StringField

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

func NewStringField

func NewStringField(definition interface{}) *StringField

func (*StringField) DefaultValue

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

func (*StringField) IsReadableBy

func (s *StringField) IsReadableBy(f AvroType, visited map[QualifiedName]interface{}) bool

func (*StringField) SerializerMethod

func (p *StringField) SerializerMethod() string

func (*StringField) WrapperType

func (s *StringField) WrapperType() string

type UnionField

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

func NewUnionField

func NewUnionField(name string, children []AvroType, definition []interface{}) *UnionField

func (*UnionField) Aliases

func (q *UnionField) Aliases() []QualifiedName

func (*UnionField) Children

func (s *UnionField) Children() []AvroType

func (*UnionField) ConstructorMethod

func (s *UnionField) ConstructorMethod() string

func (*UnionField) DefaultValue

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

func (*UnionField) Definition

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

func (*UnionField) Equals

func (s *UnionField) Equals(reader *UnionField) bool

func (*UnionField) IsReadableBy

func (s *UnionField) IsReadableBy(f AvroType, visited map[QualifiedName]interface{}) bool

func (*UnionField) ItemConstructor

func (s *UnionField) ItemConstructor(f AvroType) string

func (*UnionField) ItemName

func (s *UnionField) ItemName(item AvroType) string

func (*UnionField) ItemTypes

func (s *UnionField) ItemTypes() []AvroType

func (*UnionField) OptionalIndex

func (s *UnionField) OptionalIndex() int

func (*UnionField) QualifiedName

func (q *UnionField) QualifiedName() QualifiedName

func (*UnionField) Resolve

func (u *UnionField) Resolve(ref Reference)

Resolve runtime data when item type is a reference, since its data cannot be always known at this array's creation time.

func (*UnionField) UnionEnumType

func (s *UnionField) UnionEnumType() string

Jump to

Keyboard shortcuts

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