Files
janus/producer/get_schema.go
“nishant-sharma” f680bc4017 schema refresh endpoint
2021-05-07 20:35:35 +05:30

33 lines
619 B
Go

package producer
import (
"log"
"github.com/riferrei/srclient"
)
var (
SchemaRegistryEndpoint string
TopicList []string
SchemaVersionMap = make(map[string]int)
)
func GetSchemaVersions() {
schemaRegistryClient := srclient.CreateSchemaRegistryClient(SchemaRegistryEndpoint)
schemaRegistryClient.CodecCreationEnabled(false)
for _, topic := range TopicList {
schema, err := schemaRegistryClient.GetLatestSchema(topic, false)
if err != nil {
log.Println(err)
} else {
schemaId := schema.ID()
SchemaVersionMap[topic] = schemaId
}
}
log.Println(SchemaVersionMap)
}