X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=dmaap-mediator-producer%2Finternal%2Fconfig%2Fregistrator.go;fp=dmaap-mediator-producer%2Finternal%2Fconfig%2Fregistrator.go;h=bac14e6341fc2ace7bd0733cebdedc431f7af86d;hb=6f5d3d1eccb8a1857c645ba6bd0b5e1b89ca7088;hp=83ed43f2c375c45a7724a385dcbe5a7fd8212ece;hpb=6b43426c2b52daa5ace5205b98d09e1871fa41d6;p=nonrtric.git diff --git a/dmaap-mediator-producer/internal/config/registrator.go b/dmaap-mediator-producer/internal/config/registrator.go index 83ed43f2..bac14e63 100644 --- a/dmaap-mediator-producer/internal/config/registrator.go +++ b/dmaap-mediator-producer/internal/config/registrator.go @@ -32,11 +32,20 @@ import ( const registerTypePath = "/data-producer/v1/info-types/" const registerProducerPath = "/data-producer/v1/info-producers/" -const typeSchema = `{"type": "object","properties": {},"additionalProperties": false}` type TypeDefinition struct { - Id string `json:"id"` - DmaapTopicURL string `json:"dmaapTopicUrl"` + Identity string `json:"id"` + DMaaPTopicURL string `json:"dmaapTopicUrl"` + KafkaInputTopic string `json:"kafkaInputTopic"` + TypeSchema interface{} +} + +func (td TypeDefinition) IsKafkaType() bool { + return td.KafkaInputTopic != "" +} + +func (td TypeDefinition) IsDMaaPType() bool { + return td.DMaaPTopicURL != "" } type ProducerRegistrationInfo struct { @@ -64,8 +73,8 @@ func NewRegistratorImpl(infoCoordAddr string, client restclient.HTTPClient) *Reg func (r RegistratorImpl) RegisterTypes(jobTypes []TypeDefinition) error { for _, jobType := range jobTypes { - body := fmt.Sprintf(`{"info_job_data_schema": %v}`, typeSchema) - if error := restclient.Put(r.infoCoordinatorAddress+registerTypePath+url.PathEscape(jobType.Id), []byte(body), r.httpClient); error != nil { + body := fmt.Sprintf(`{"info_job_data_schema": %v}`, jobType.TypeSchema) + if error := restclient.Put(r.infoCoordinatorAddress+registerTypePath+url.PathEscape(jobType.Identity), []byte(body), r.httpClient); error != nil { return error } log.Debugf("Registered type: %v", jobType)