sarama_x

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 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

Jump to

Keyboard shortcuts

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