X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=dmaap-mediator-producer%2Finternal%2Fconfig%2Fregistrator.go;h=1dd0ad1c605f1167700f294b8a20f06443369d5c;hb=3287cf6923fe9b6f768a10e9d7a852227e1a3949;hp=83ed43f2c375c45a7724a385dcbe5a7fd8212ece;hpb=0af0d6013c831bfea032c34ce85e1dcf28b10855;p=nonrtric.git diff --git a/dmaap-mediator-producer/internal/config/registrator.go b/dmaap-mediator-producer/internal/config/registrator.go index 83ed43f2..1dd0ad1c 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,9 @@ 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 { + s, _ := json.Marshal(jobType.TypeSchema) + body := fmt.Sprintf(`{"info_job_data_schema": %v}`, string(s)) + 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)