Documentation ¶
Index ¶
- Constants
- func NewArrayField(itemType AvroType, definition map[string]interface{}) *arrayField
- func NewBoolField(definition interface{}) *boolField
- func NewBytesField(definition interface{}) *bytesField
- func NewDoubleField(definition interface{}) *doubleField
- func NewFloatField(definition interface{}) *floatField
- func NewIntField(definition interface{}) *intField
- func NewLongField(definition interface{}) *longField
- func NewMapField(itemType AvroType, definition map[string]interface{}) *mapField
- func NewNullField(definition interface{}) *nullField
- func NewStringField(definition interface{}) *stringField
- func NewUnionField(name string, itemType []AvroType, definition []interface{}) *unionField
- type AvroType
- type Constructable
- type Definition
- type EnumDefinition
- func (e *EnumDefinition) AddDeserializer(p *generator.Package)
- func (e *EnumDefinition) AddSerializer(p *generator.Package)
- func (e *EnumDefinition) AddStruct(p *generator.Package, _ bool) error
- func (e *EnumDefinition) Aliases() []QualifiedName
- func (e *EnumDefinition) AvroName() QualifiedName
- func (s *EnumDefinition) DefaultValue(lvalue string, rvalue interface{}) (string, error)
- func (s *EnumDefinition) Definition(scope map[QualifiedName]interface{}) (interface{}, error)
- func (e *EnumDefinition) DeserializerMethod() string
- func (e *EnumDefinition) GoType() string
- func (e *EnumDefinition) Name() string
- func (s *EnumDefinition) ResolveReferences(n *Namespace) error
- func (e *EnumDefinition) SerializerMethod() string
- func (e *EnumDefinition) SimpleName() string
- type Field
- func (f *Field) Default() interface{}
- func (f *Field) Definition(scope map[QualifiedName]interface{}) (map[string]interface{}, error)
- func (f *Field) Doc() string
- func (f *Field) GoName() string
- func (f *Field) HasDefault() bool
- func (f *Field) Name() string
- func (f *Field) SimpleName() string
- func (f *Field) Tags() string
- func (f *Field) Type() AvroType
- type FixedDefinition
- func (s *FixedDefinition) AddDeserializer(p *generator.Package)
- func (s *FixedDefinition) AddSerializer(p *generator.Package)
- func (s *FixedDefinition) AddStruct(p *generator.Package, _ bool) error
- func (s *FixedDefinition) Aliases() []QualifiedName
- func (s *FixedDefinition) AvroName() QualifiedName
- func (s *FixedDefinition) DefaultValue(lvalue string, rvalue interface{}) (string, error)
- func (s *FixedDefinition) Definition(scope map[QualifiedName]interface{}) (interface{}, error)
- func (s *FixedDefinition) DeserializerMethod() string
- func (s *FixedDefinition) GoType() string
- func (s *FixedDefinition) Name() string
- func (s *FixedDefinition) ResolveReferences(n *Namespace) error
- func (s *FixedDefinition) SerializerMethod() string
- func (s *FixedDefinition) SimpleName() string
- type Namespace
- type QualifiedName
- type RecordDefinition
- func (r *RecordDefinition) AddDeserializer(p *generator.Package)
- func (r *RecordDefinition) AddSerializer(p *generator.Package)
- func (r *RecordDefinition) AddStruct(p *generator.Package, containers bool) error
- func (r *RecordDefinition) Aliases() []QualifiedName
- func (r *RecordDefinition) AvroName() QualifiedName
- func (r *RecordDefinition) ConstructorMethod() string
- func (r *RecordDefinition) ConstructorMethodDef() (string, error)
- func (r *RecordDefinition) DefaultValue(lvalue string, rvalue interface{}) (string, error)
- func (r *RecordDefinition) Definition(scope map[QualifiedName]interface{}) (interface{}, error)
- func (r *RecordDefinition) DeserializerMethod() string
- func (r *RecordDefinition) FieldByName(name string) *Field
- func (r *RecordDefinition) GoType() string
- func (r *RecordDefinition) Name() string
- func (r *RecordDefinition) ResolveReferences(n *Namespace) error
- func (r *RecordDefinition) SerializerMethod() string
- func (r *RecordDefinition) SimpleName() string
- type Reference
- func (s *Reference) AddDeserializer(p *generator.Package)
- func (s *Reference) AddSerializer(p *generator.Package)
- func (s *Reference) AddStruct(p *generator.Package, containers bool) error
- func (s *Reference) DefaultValue(lvalue string, rvalue interface{}) (string, error)
- func (s *Reference) Definition(scope map[QualifiedName]interface{}) (interface{}, error)
- func (s *Reference) DeserializerMethod() string
- func (s *Reference) GoType() string
- func (s *Reference) Name() string
- func (s *Reference) ResolveReferences(n *Namespace) error
- func (s *Reference) SerializerMethod() string
- func (s *Reference) SimpleName() string
- type RequiredMapKeyError
- type Schema
- type SchemaError
- type WrongMapValueTypeError
Constants ¶
View Source
const UTIL_FILE = "primitive.go"
Variables ¶
This section is empty.
Functions ¶
func NewArrayField ¶
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 NewNullField ¶
func NewNullField(definition interface{}) *nullField
func NewStringField ¶
func NewStringField(definition interface{}) *stringField
func NewUnionField ¶
Types ¶
type AvroType ¶
type AvroType interface { Name() string SimpleName() 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 SimpleName() 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, doc 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
func (*EnumDefinition) SimpleName ¶
func (e *EnumDefinition) SimpleName() string
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
func (*Field) Definition ¶
func (f *Field) Definition(scope map[QualifiedName]interface{}) (map[string]interface{}, error)
func (*Field) HasDefault ¶
func (*Field) SimpleName ¶
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
func (*FixedDefinition) SimpleName ¶
func (s *FixedDefinition) SimpleName() 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 (*Namespace) AddToPackage ¶
func (*Namespace) RegisterDefinition ¶
func (n *Namespace) RegisterDefinition(d Definition) error
RegisterDefinition adds a new type definition to the namespace. Returns an error if the type is already defined.
func (*Namespace) TypeForSchema ¶
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 QualifiedName ¶
QualifiedName represents an Avro qualified name, which includes an optional namespace and the type name.
func ParseAvroName ¶
func ParseAvroName(enclosing, name string) 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
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, doc string, 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
func (*RecordDefinition) SimpleName ¶
func (r *RecordDefinition) SimpleName() string
type Reference ¶
type Reference struct {
// contains filtered or unexported fields
}
func NewReference ¶
func NewReference(typeName QualifiedName) *Reference
func (*Reference) AddDeserializer ¶
func (*Reference) AddSerializer ¶
func (*Reference) DefaultValue ¶
func (*Reference) Definition ¶
func (s *Reference) Definition(scope map[QualifiedName]interface{}) (interface{}, error)
func (*Reference) DeserializerMethod ¶
func (*Reference) ResolveReferences ¶
func (*Reference) SerializerMethod ¶
func (*Reference) SimpleName ¶
type RequiredMapKeyError ¶
type RequiredMapKeyError struct {
Key string
}
func NewRequiredMapKeyError ¶
func NewRequiredMapKeyError(key string) *RequiredMapKeyError
func (*RequiredMapKeyError) Error ¶
func (r *RequiredMapKeyError) Error() string
type SchemaError ¶
func NewSchemaError ¶
func NewSchemaError(fieldName string, err error) *SchemaError
func (*SchemaError) Error ¶
func (s *SchemaError) Error() string
type WrongMapValueTypeError ¶
func NewWrongMapValueTypeError ¶
func NewWrongMapValueTypeError(key, expectedType string, actualValue interface{}) *WrongMapValueTypeError
func (*WrongMapValueTypeError) Error ¶
func (w *WrongMapValueTypeError) Error() string
Click to show internal directories.
Click to hide internal directories.