avro

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultValue

func DefaultValue(t any) any

func FullName

func FullName(t NamedType) string

func LogMsg

func LogMsg(msg string, args ...any)

func LogObj

func LogObj(arg any)

Types

type Array

type Array struct {
	Items Type
}

func (Array) ToJSON

func (t Array) ToJSON(types *TypeRepo) (any, error)

type Bare

type Bare string

func (Bare) ToJSON

func (b Bare) ToJSON(_ *TypeRepo) (any, error)

type Enum

type Enum struct {
	Name      string
	Namespace string
	Symbols   []string
	Default   string
}

func EnumFromProto

func EnumFromProto(proto *descriptorpb.EnumDescriptorProto, protoPackage string) Enum

func (Enum) GetName

func (t Enum) GetName() string

func (Enum) GetNamespace

func (t Enum) GetNamespace() string

func (Enum) ToJSON

func (t Enum) ToJSON(repo *TypeRepo) (any, error)

type Field

type Field struct {
	Name    string
	Type    Type
	Default any
}

func FieldFromProto

func FieldFromProto(proto *descriptorpb.FieldDescriptorProto) Field

func (Field) ToJSON

func (t Field) ToJSON(types *TypeRepo) (any, error)

type Map

type Map struct {
	Name      string
	Namespace string
	Values    Type
}

func (Map) GetName

func (t Map) GetName() string

func (Map) GetNamespace

func (t Map) GetNamespace() string

func (Map) ToJSON

func (t Map) ToJSON(types *TypeRepo) (any, error)

type NamedType

type NamedType interface {
	Type
	GetName() string
	GetNamespace() string
}

func RecordFromProto

func RecordFromProto(proto *descriptorpb.DescriptorProto, namespace string, typeRepo *TypeRepo) []NamedType

type Record

type Record struct {
	Name      string
	Namespace string
	Fields    []Field
}

func (Record) GetName

func (t Record) GetName() string

func (Record) GetNamespace

func (t Record) GetNamespace() string

func (Record) ToJSON

func (t Record) ToJSON(types *TypeRepo) (any, error)

type Ref

type Ref string

Ref represents a reference to an existing record/enum

func (Ref) ToJSON

func (r Ref) ToJSON(types *TypeRepo) (any, error)

type Type

type Type interface {
	ToJSON(*TypeRepo) (any, error)
}

func BasicFieldTypeFromProto

func BasicFieldTypeFromProto(proto *descriptorpb.FieldDescriptorProto) Type

func FieldTypeFromProto

func FieldTypeFromProto(proto *descriptorpb.FieldDescriptorProto) Type

type TypeRepo

type TypeRepo struct {
	Types map[string]NamedType

	NamespaceMap          map[string]string
	CollapseFields        []string
	RemoveEnumPrefixes    bool
	PreserveNonStringMaps bool
	// contains filtered or unexported fields
}

func NewTypeRepo

func NewTypeRepo(params input.Params) *TypeRepo

func (*TypeRepo) AddType

func (r *TypeRepo) AddType(t NamedType)

func (*TypeRepo) GetType

func (r *TypeRepo) GetType(name string) (Type, error)

func (*TypeRepo) GetTypeByBareName

func (r *TypeRepo) GetTypeByBareName(name string) Type

func (*TypeRepo) LogTypes

func (r *TypeRepo) LogTypes()

func (*TypeRepo) MappedNamespace

func (r *TypeRepo) MappedNamespace(namespace string) string

func (*TypeRepo) SeenType

func (r *TypeRepo) SeenType(t NamedType)

func (*TypeRepo) Start

func (r *TypeRepo) Start()

type Union

type Union struct {
	Types []Type
}

func (Union) ToJSON

func (u Union) ToJSON(types *TypeRepo) (any, error)

Jump to

Keyboard shortcuts

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