31 lines
600 B
Go
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)
|
|
|
|
} |