Skip to content

Latest commit

 

History

History
49 lines (37 loc) · 1.59 KB

README.md

File metadata and controls

49 lines (37 loc) · 1.59 KB

Schema Registry Client

GoDoc

This repository contains wrapper function to communicate Confluent's Kafka schema registry via REST API and schema dynamic sync directly from kafka topic.

Client

Download library using go get -u github.com/tryfix/schema-registry

Following code slice create a schema registry client

import schemaregistry "github.com/tryfix/schemaregistry"

registry, _ := schemaregistry.NewRegistry(`localhost:8089/`)

Following code line register an event com.pickme.events.test with version 1

import schemaregistry "github.com/tryfix/schemaregistry"

registry.Register(`com.pickme.events.test`, 1, func(data []byte) (v interface{}, err error)

Dynamically sync schema's from kafka schema data topic

import schemaregistry "github.com/tryfix/schemaregistry"

registry, _ := schemaregistry.NewRegistry(`localhost:8089/`,schemaregistry.WithBackgroundSync([]string{`localhost:9092`}, `__schemas`))
registry.Sync()

Message Structure

Avro encoded events are published with magic byte and schema Id added to it. Following structure shows the message format used in the library to encode the message.

+====================+====================+======================+
| Magic byte(1 byte) | Schema ID(4 bytes) | AVRO encoded message |
+====================+====================+======================+

ToDo

  • Write unit test
  • Write mock functions
  • write benchmarks
  • setup travis for automated testing