33 lines
619 B
Go
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)
|
|
|
|
} |