types

package
v4.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const UTIL_FILE = "primitive.go"

Variables

This section is empty.

Functions

func AddUUIDSerializerToPackage

func AddUUIDSerializerToPackage(pkg *generator.Package, requiredSerializers []string)

AddUUIDSerializerToPackage will add a file with Serializer functions to the generated package code

Types

type Definition

type Definition interface {
	AvroName() QualifiedName
	Aliases() []QualifiedName
	// The friendly name for the type
	FieldType() string
	// The corresponding Go type
	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)
	// 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)
	ResolveReferences(*Namespace) error
	Schema(names map[QualifiedName]interface{}) interface{}
}

type EnumDefinition

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

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)

func (*EnumDefinition) Aliases

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

func (*EnumDefinition) AvroName

func (e *EnumDefinition) AvroName() QualifiedName

func (*EnumDefinition) DeserializerMethod

func (e *EnumDefinition) DeserializerMethod() string

func (*EnumDefinition) FieldType

func (e *EnumDefinition) FieldType() string

func (*EnumDefinition) GoType

func (e *EnumDefinition) GoType() string

func (*EnumDefinition) ResolveReferences

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

func (*EnumDefinition) Schema

func (s *EnumDefinition) Schema(names map[QualifiedName]interface{}) interface{}

func (*EnumDefinition) SerializerMethod

func (e *EnumDefinition) SerializerMethod() string

type Field

type Field interface {
	// The field name in the schema definition
	AvroName() string
	// The field name in the Go struct
	GoName() string
	// The friendly type name
	FieldType() string
	// Default value for the field
	HasDefault() bool
	Default() interface{}
	// The corresponding Go type
	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)
	// 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
	// Get the objects that will serialize to the normalized JSON schema
	Schema(names map[QualifiedName]interface{}) interface{}
}

* The interface implemented by all Avro field types.

type FixedDefinition

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

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)

func (*FixedDefinition) Aliases

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

func (*FixedDefinition) AvroName

func (s *FixedDefinition) AvroName() QualifiedName

func (*FixedDefinition) DeserializerMethod

func (s *FixedDefinition) DeserializerMethod() string

func (*FixedDefinition) FieldType

func (s *FixedDefinition) FieldType() string

func (*FixedDefinition) GoType

func (s *FixedDefinition) GoType() string

func (*FixedDefinition) ResolveReferences

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

func (*FixedDefinition) Schema

func (s *FixedDefinition) Schema(names map[QualifiedName]interface{}) interface{}

func (*FixedDefinition) SerializerMethod

func (s *FixedDefinition) SerializerMethod() string

type Namespace

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

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

func NewNamespace

func NewNamespace() *Namespace

func (*Namespace) FieldDefinitionForSchema

func (n *Namespace) FieldDefinitionForSchema(schemaJson []byte) (Field, error)
Given an Avro schema as a JSON string, decode it and return the Field 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 Field defined at the top level and all the type definitions beneath it will also be added to this Namespace.

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.

type PrimitiveType

type PrimitiveType struct {
	AvroType                     string
	GoType                       string
	SerializerMethod             string
	DeserializerMethod           string
	SerializerMethodDefinition   string
	DeserializerMethodDefinition string
}

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 (*RecordDefinition) AddDeserializer

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

func (*RecordDefinition) AddGenerateID

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

AddGenerateID adds a GenerateID method which creates a uuidV5 from a set of fields

func (*RecordDefinition) AddSendStats

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

AddSendStats add a SendStats method which submits stats for this record

func (*RecordDefinition) AddSerializer

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

func (*RecordDefinition) AddStruct

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

func (*RecordDefinition) Aliases

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

func (*RecordDefinition) AvroName

func (r *RecordDefinition) AvroName() QualifiedName

func (*RecordDefinition) DeserializerMethod

func (r *RecordDefinition) DeserializerMethod() string

func (*RecordDefinition) FieldType

func (r *RecordDefinition) FieldType() string

func (*RecordDefinition) GoType

func (r *RecordDefinition) GoType() string

func (*RecordDefinition) ResolveReferences

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

func (*RecordDefinition) Schema

func (r *RecordDefinition) Schema(names map[QualifiedName]interface{}) interface{}

func (*RecordDefinition) SerializerMethod

func (r *RecordDefinition) SerializerMethod() string

type Reference

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

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)

func (*Reference) AvroName

func (s *Reference) AvroName() string

func (*Reference) Default

func (s *Reference) Default() interface{}

func (*Reference) Definition

func (s *Reference) Definition() Definition

func (*Reference) DeserializerMethod

func (s *Reference) DeserializerMethod() string

func (*Reference) FieldType

func (s *Reference) FieldType() string

func (*Reference) GoName

func (s *Reference) GoName() string

func (*Reference) GoType

func (s *Reference) GoType() string

func (*Reference) HasDefault

func (s *Reference) HasDefault() bool

func (*Reference) ResolveReferences

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

func (*Reference) Schema

func (s *Reference) Schema(names map[QualifiedName]interface{}) interface{}

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       Field
	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