sarama_x

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const AvroTypeRecord = "record"
View Source
const SubjectPostfixValue = "value"

Variables

View Source
var AvroSchemaCache = map[string]AvroSchemaCacheObj{}

AvroSchemaCache is for creating a cache of schemas

View Source
var AvroSchemaRegistryCache = map[int]*srclient.Schema{}
View Source
var ErrNoRegistryHostDefined = errors.New("no registry host is defined")
View Source
var ErrSubjectNotFound = errors.New("404 Not Found: Subject in Schema Registry")
View Source
var RegistryHost = ""

Functions

func ApplyAvroEncoding

func ApplyAvroEncoding(namespace string, encoded []byte, err error, name string, encoder sarama.Encoder) ([]byte, error)

ApplyAvroEncoding uses the schema registry

func CreateSchemaForSubject

func CreateSchemaForSubject(subject, namespace, name string, encoder sarama.Encoder) (*srclient.Schema, error)

func EnsureAvroEncoded

func EnsureAvroEncoded(namespace string, encoded []byte, err error, name string, encoder sarama.Encoder) ([]byte, error)

EnsureAvroEncoded avro encodes the type

func EnsureEncoded

func EnsureEncoded(encoded []byte, err error, encoder sarama.Encoder) ([]byte, error)

EnsureEncoded json encodes the type

func GetAvroSchemaJson

func GetAvroSchemaJson(namespace string, name string, data interface{}) (schemaJson []byte)

GetAvroSchemaJson scans struct to create avro schema json []byte

func GetSchemaById

func GetSchemaById(schemaId int) (*srclient.Schema, error)

func GetSchemaBySubject

func GetSchemaBySubject(subject string) (*srclient.Schema, error)

func MatchSchemaForSubject

func MatchSchemaForSubject(subject, namespace, name string, existingSchema string, encoder sarama.Encoder) bool

func SetCompatibilityForSubject

func SetCompatibilityForSubject(subject string) (bool, error)

Types

type AvroSchema

type AvroSchema struct {
	Namespace string            `json:"namespace"`
	Type      string            `json:"type"`
	Name      string            `json:"name"`
	Fields    []AvroSchemaField `json:"fields"`
}

AvroSchema is the schema for a struct type

func GenerateAvroSchema

func GenerateAvroSchema(namespace string, name string, data interface{}, values *reflect.Value) (schema AvroSchema)

GenerateAvroSchema scans struct to create avro schema

func GetAvroSchema

func GetAvroSchema(namespace string, name string, data interface{}) (schema AvroSchema)

type AvroSchemaCacheObj

type AvroSchemaCacheObj struct {
	Json   []byte
	Schema AvroSchema
}

AvroSchemaCacheObj is a a single cache object that will store schema object and json

type AvroSchemaField

type AvroSchemaField struct {
	Name string      `json:"name"`
	Type interface{} `json:"type"`
}

AvroSchemaField is a single field for the schema

type AvroSchemaMap

type AvroSchemaMap struct {
	Type   string      `json:"type"`
	Values interface{} `json:"values"`
}

AvroSchemaMap is a single map field for the schema

type SchemaRegistryHost added in v0.2.2

type SchemaRegistryHost struct {
	RegistryHost            string
	AvroSchemaCache         map[string]AvroSchemaCacheObj
	AvroSchemaRegistryCache map[int]*srclient.Schema
}

func (*SchemaRegistryHost) ApplyAvroEncoding added in v0.2.2

func (host *SchemaRegistryHost) ApplyAvroEncoding(namespace string, encoded []byte, err error, name string, encoder sarama.Encoder) ([]byte, error)

ApplyAvroEncoding uses the schema registry

func (*SchemaRegistryHost) CreateSchemaForSubject added in v0.2.2

func (host *SchemaRegistryHost) CreateSchemaForSubject(subject, namespace, name string, encoder sarama.Encoder) (*srclient.Schema, error)

func (*SchemaRegistryHost) EnsureAvroEncoded added in v0.2.2

func (host *SchemaRegistryHost) EnsureAvroEncoded(namespace string, encoded []byte, err error, name string, encoder sarama.Encoder) ([]byte, error)

EnsureAvroEncoded avro encodes the type

func (*SchemaRegistryHost) GenerateAvroSchema added in v0.2.2

func (host *SchemaRegistryHost) GenerateAvroSchema(namespace string, name string, data interface{}, values *reflect.Value) (schema AvroSchema)

GenerateAvroSchema scans struct to create avro schema

func (*SchemaRegistryHost) GetAvroSchema added in v0.2.2

func (host *SchemaRegistryHost) GetAvroSchema(namespace string, name string, data interface{}) (schema AvroSchema)

func (*SchemaRegistryHost) GetAvroSchemaJson added in v0.2.2

func (host *SchemaRegistryHost) GetAvroSchemaJson(namespace string, name string, data interface{}) (schemaJson []byte)

GetAvroSchemaJson scans struct to create avro schema json []byte

func (*SchemaRegistryHost) GetSchemaById added in v0.2.2

func (host *SchemaRegistryHost) GetSchemaById(schemaId int) (*srclient.Schema, error)

func (*SchemaRegistryHost) GetSchemaBySubject added in v0.2.2

func (host *SchemaRegistryHost) GetSchemaBySubject(subject string) (*srclient.Schema, error)

func (*SchemaRegistryHost) Init added in v0.2.2

func (host *SchemaRegistryHost) Init(schemaHost string) error

func (*SchemaRegistryHost) MatchSchemaForSubject added in v0.2.2

func (host *SchemaRegistryHost) MatchSchemaForSubject(subject, namespace, name string, existingSchema string, encoder sarama.Encoder) bool

func (*SchemaRegistryHost) SetCompatibilityForSubject added in v0.2.2

func (host *SchemaRegistryHost) SetCompatibilityForSubject(subject string) (bool, error)

Jump to

Keyboard shortcuts

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