diff options
author | 2019-10-15 00:48:18 +0000 | |
---|---|---|
committer | 2019-10-15 13:30:04 +0000 | |
commit | 99f7370360201104ddfc99b5e766b4e32e8524cc (patch) | |
tree | 9e7dbc4db186e85afd0654b64bdb4cabdb7b81ab /vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/kafka-config.go | |
parent | 3289af42fd3af32fd07c565d072c65743249ebce (diff) |
HDFSWriter microservice working copy
Issue-ID: ONAPARC-453
Signed-off-by: Rajamohan Raj <rajamohan.raj@intel.com>
Change-Id: I11c91b642e466763c1ca6f5734bf81fb260e2b39
Diffstat (limited to 'vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/kafka-config.go')
-rw-r--r-- | vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/kafka-config.go | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/kafka-config.go b/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/kafka-config.go new file mode 100644 index 00000000..080bfd4b --- /dev/null +++ b/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/kafka-config.go @@ -0,0 +1,55 @@ +package utils + + +import ( + "os" +) + +// SetKafkaParametersByObjectMap sets the value of the kafka parameters +// and sets the KafkaConfig object +func SetKafkaParametersByObjectMap(m map[string]interface{}) KafkaConfig { + kc := KafkaConfig{} + kc.broker = m["broker"].(string) + kc.group = m["group"].(string) + kc.topic = m["topic"].(string) + + return kc +} + +// SetKafkaParametersByEnvVariables sets the kafka parameters +func SetKafkaParametersByEnvVariables() KafkaConfig { + slogger := GetLoggerInstance() + + kafkaConfigObject := KafkaConfig{ + broker: os.Getenv("BROKER"), + group: os.Getenv("GROUP"), + topic: os.Getenv("TOPIC"), + } + slogger.Infof("::broker:: %s", kafkaConfigObject.broker) + slogger.Infof("::group:: %s", kafkaConfigObject.group) + slogger.Infof("::topic:: %s", kafkaConfigObject.topic) + + return kafkaConfigObject +} + +// KafkaConfig contains all the config parameters needed for kafka. This can be extended over time +type KafkaConfig struct { + broker string + group string + topic string +} + +// GetBroker returns kafka broker configured +func (k KafkaConfig) GetBroker() string { + return k.broker +} + +// GetGroup returns kafka group configured +func (k KafkaConfig) GetGroup() string { + return k.group +} + +// GetTopic returns kafka topic configured +func (k KafkaConfig) GetTopic() string { + return k.topic +}
\ No newline at end of file |