X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=dmaap-mediator-producer%2Finternal%2Fconfig%2Fconfig.go;h=9b7b1dd1544b184141abe4546a40a3430e09413e;hb=b65d86fc9b02415e1adf2415f8c4a257378e9c09;hp=a3e3a119a2f1d42f5c7382e8d16a1d30a376d993;hpb=4f552adc8e623109f1c10bfaede709fa8db039f7;p=nonrtric.git diff --git a/dmaap-mediator-producer/internal/config/config.go b/dmaap-mediator-producer/internal/config/config.go index a3e3a119..9b7b1dd1 100644 --- a/dmaap-mediator-producer/internal/config/config.go +++ b/dmaap-mediator-producer/internal/config/config.go @@ -22,13 +22,18 @@ package config import ( "os" + "strconv" + + log "github.com/sirupsen/logrus" ) type Config struct { - LogLevel string - InfoJobCallbackUrl string - InfoCoordinatorAddress string - InfoProducerSupervisionCallbackUrl string + LogLevel string + InfoProducerHost string + InfoProducerPort int + InfoCoordinatorAddress string + MRHost string + MRPort int } type ProducerRegistrationInfo struct { @@ -39,10 +44,12 @@ type ProducerRegistrationInfo struct { func New() *Config { return &Config{ - LogLevel: getEnv("LOG_LEVEL", "Info"), - InfoJobCallbackUrl: getEnv("INFO_JOB_CALLBACK_URL", ""), - InfoCoordinatorAddress: getEnv("INFO_COORD_ADDR", "http://enrichmentservice:8083"), - InfoProducerSupervisionCallbackUrl: getEnv("INFO_PRODUCER_SUPERVISION_CALLBACK_URL", ""), + LogLevel: getEnv("LOG_LEVEL", "Info"), + InfoProducerHost: getEnv("INFO_PRODUCER_HOST", ""), + InfoProducerPort: getEnvAsInt("INFO_PRODUCER_PORT", 8085), + InfoCoordinatorAddress: getEnv("INFO_COORD_ADDR", "http://enrichmentservice:8083"), + MRHost: getEnv("MR_HOST", "http://message-router.onap"), + MRPort: getEnvAsInt("MR_PORT", 3904), } } @@ -53,3 +60,14 @@ func getEnv(key string, defaultVal string) string { return defaultVal } + +func getEnvAsInt(name string, defaultVal int) int { + valueStr := getEnv(name, "") + if value, err := strconv.Atoi(valueStr); err == nil { + return value + } else if valueStr != "" { + log.Warnf("Invalid int value: %v for variable: %v. Default value: %v will be used", valueStr, name, defaultVal) + } + + return defaultVal +}