avro

package
v2.8.4 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPayloadToShort   = errors.New("payload too short")
	ErrInvalidMagicByte = errors.New("invalid magic byte value")
)

Functions

func DeserializeWithSchema added in v2.6.5

func DeserializeWithSchema[E any](schemas confluent.Client, deser Deserializer[E], payload []byte) (E, error)

func EventTypeOf added in v2.6.5

func EventTypeOf(event Event) string

func SerializeWithSchema added in v2.6.5

func SerializeWithSchema(client confluent.Client, event Event) ([]byte, error)

func SerializeWithSchemaId added in v2.6.5

func SerializeWithSchemaId(schemaId uint32, event Event) ([]byte, error)

Types

type Converter

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

func NewConverter

func NewConverter(registry *SchemaCache, options ConverterOptions) *Converter

func (*Converter) ConvertAvroToGo added in v2.2.55

func (c *Converter) ConvertAvroToGo(input any) any

func (*Converter) Parse

func (c *Converter) Parse(ctx context.Context, data []byte) (map[string]any, *EventSource, error)

type ConverterOptions added in v2.1.19

type ConverterOptions struct {
	AvroNamespace string // prefix for namespace prefix which will be used to identify self defined records
	ToLowerCase   bool   // map all field names to lower case
}

type Deserializer added in v2.6.5

type Deserializer[E any] func(r io.Reader, schema string) (E, error)

type Event added in v2.6.5

type Event interface {
	// Schema returns the avro schema of this event
	Schema() string

	// Serialize writes the event (in avro format) to the given writer.
	Serialize(io.Writer) error
}

type EventSource

type EventSource struct {
	Record any
	Schema string
}

type SchemaCache added in v2.6.5

type SchemaCache struct {
	ConfluentClient confluent.Client
	// contains filtered or unexported fields
}

SchemaCache is a wrapper around a ConfluentClient that caches the schemas as parsed goavro.Codec instances.

func (*SchemaCache) Get added in v2.6.5

func (r *SchemaCache) Get(ctx context.Context, schemaId uint32) (*goavro.Codec, error)

Jump to

Keyboard shortcuts

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