This is a golang-client for schemakeeper.
go dep github.com/nryanov/schemakeeper-go 0.2.0
package main
import (
"fmt"
"github.com/linkedin/goavro/v2"
"github.com/nryanov/schemakeeper-go"
)
func main() {
codec, err := goavro.NewCodec(`{"type": "record","name": "test","fields" : [{"name": "f1", "type": "long"},{"name": "f2", "type": ["null", "string"]}]}`)
if err != nil {
fmt.Println(err)
}
cfg := schemakeepergo.CreateConfiguration("host:port")
client := schemakeepergo.CreateCachedSchemaKeeperClient(cfg)
serializer := schemakeepergo.CreateAvroSerializer(cfg, client)
deserializer := schemakeepergo.CreateAvroDeserializer(cfg, client)
value := make(map[string]interface{})
value["f1"] = int64(1)
value["f2"] = goavro.Union("string", "value")
data, err := serializer.Serialize("subjectName", value, codec)
if err != nil {
fmt.Println(err)
}
record, err := deserializer.Deserialize(data)
if err != nil {
fmt.Println(err)
}
fmt.Println(record)
}
Currently, this client supports only avro serialization/deserialization.