Files
janus/producer/get_schema.go
2021-03-30 16:03:09 +05:30

31 lines
600 B
Go

package producer
import (
"log"
"github.com/riferrei/srclient"
)
var (
SchemaVersionMap = make(map[string]int)
)
func GetSchemaVersions(schemaRegistryEndpoint string, topicList []string) {
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)
}