DE-1338 | removing schema registry dependency
This commit is contained in:
1
main.go
1
main.go
@@ -27,7 +27,6 @@ func init() {
|
||||
port = configs.Server.Port
|
||||
logger.Debug("Service started on PORT: " + port)
|
||||
logger.Debug("Kafka Bootstrap Servers: " + configs.Kafka.Bootstrap_Servers)
|
||||
schema.InitializeSchemaHandler(configs)
|
||||
producer_client.InitializeProducers(configs.Kafka, configs.Env)
|
||||
logger.Info("Producer Initialized, starting goroutines for event processing")
|
||||
for i := 0; i < configs.Server.Goroutines; i++ {
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"com.navi.medici.janus/config"
|
||||
"com.navi.medici.janus/utils"
|
||||
"fmt"
|
||||
"github.com/riferrei/srclient"
|
||||
"go.uber.org/zap"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
SchemaRegistryEndpoint string
|
||||
TopicList []string
|
||||
SchemaVersionMap = make(map[string]int)
|
||||
logger *zap.Logger
|
||||
)
|
||||
|
||||
func InitializeSchemaHandler(configuration config.Configurations) {
|
||||
logger = utils.GetLogger()
|
||||
SchemaRegistryEndpoint = configuration.SchemaRegistry.Endpoint
|
||||
TopicList = strings.Split(configuration.SchemaRegistry.Topics, ",")
|
||||
// initialize schema version map which contains latest schema version for topic(s)
|
||||
GetSchemaVersions()
|
||||
}
|
||||
|
||||
func GetSchemaVersions() {
|
||||
|
||||
schemaRegistryClient := srclient.CreateSchemaRegistryClient(SchemaRegistryEndpoint)
|
||||
schemaRegistryClient.CodecCreationEnabled(false)
|
||||
for _, topic := range TopicList {
|
||||
schema, err := schemaRegistryClient.GetLatestSchema(topic, false)
|
||||
if err != nil {
|
||||
logger.Error("error in fetching latest schema", zap.Error(err))
|
||||
} else {
|
||||
schemaId := schema.ID()
|
||||
SchemaVersionMap[topic] = schemaId
|
||||
}
|
||||
}
|
||||
logger.Debug("Schema Version Map", zap.String("", fmt.Sprintf("%v", SchemaVersionMap)))
|
||||
}
|
||||
Reference in New Issue
Block a user