Merge "Add docker-compose files for dmaap-mediator"
[nonrtric.git] / dmaap-mediator-producer / internal / config / config.go
index a3e3a11..9b7b1dd 100644 (file)
@@ -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
+}