schreg

package module
v0.0.0-...-60464f8 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: MIT Imports: 11 Imported by: 0

README

schreg

At a certain point in a project I needed a Schema Registry for Kafka which allowing me to ignore compatibility rules in a subject.

This little module is designed to work with Cofluent's Schema Registry.

This Schema Registry basically posts every new schema to a default subject, whose compatibility level was set to NONE at startup, in order to sink there every schema. This comes useful for Go application needing to regenrate their schemas dynamically according to varying stuff, like user interactions.

The module is designed in order to be integrated with Hamba's Avro library , in order to directl;y gather their structs instead of strings.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSchema

func GetSchema(schema_registry_url string, id int) (avro.Schema, error)

func IsSchemaIdValid

func IsSchemaIdValid(schema_id int) bool

Just a function containing a basic logic to check if an id is valid or not

func PostSchema

func PostSchema(schema avro.Schema, schema_registry_url string, subject string) (int, error)

func PostSubjectCompatibilityLevel

func PostSubjectCompatibilityLevel(compatibility_level compatibility_levels.CompatibilityLevel, schema_registry_url string, subject string) (compatibility_levels.CompatibilityLevel, error)

Function aimed at setting the compatibility level on a given subject. It received a predefined compatibility level, the url of a schema registry (to which it will attach the route towards the subject configuration) and the subject. The function will output the resulting compatibility level on the subject, together with eventual errors

Types

type SchemaRegistryClient

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

Struct aimed at representing the Client entitled to interact with the schema registry through http

func NewSchemaRegistryClient

func NewSchemaRegistryClient(input_registry_url string, input_dynamic_subject string) *SchemaRegistryClient

Function aimed at providing a new client

func (*SchemaRegistryClient) GetSchemaByID

func (client *SchemaRegistryClient) GetSchemaByID(id int) (avro.Schema, error)

func (*SchemaRegistryClient) GetSchemaID

func (client *SchemaRegistryClient) GetSchemaID(schema avro.Schema) (int, error)

Method which return the id in the schema registry of a schema given a hamba avro Schema interface. It will first query the internal cache, and then if the schema is not present, it will send a Post request for the schema id via http to the schema registry.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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