From 09c016b16bed7125be0f4173d1d131aa2fed476b Mon Sep 17 00:00:00 2001 From: Lohith KM Date: Wed, 28 Oct 2020 22:08:05 +0530 Subject: [PATCH 1/2] #68 | Kafka or Rabbitmq to be optional to use Clamp based on ENV, presently disabling it by default --- .circleci/config.yml | 2 ++ config/env.go | 3 +++ main.go | 8 ++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fbf597a..58f453f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -65,6 +65,8 @@ jobs: CLAMP_DB_CONNECTION_STR: "host=localhost:5432 user=clamptest dbname=clamptest" CLAMP_KAFKA_CONNECTION_STR: "localhost:9092" CLAMP_QUEUE_CONNECTION_STR: "amqp://guest:guest@localhost:5672/" + ENABLE_KAFKA_INTEGRATION: true + EnableRabbitMQIntegration: true command: | if [ $CIRCLE_BRANCH == 'master' ]; then ./cc-test-reporter before-build diff --git a/config/env.go b/config/env.go index 370404c..9bf5ee1 100644 --- a/config/env.go +++ b/config/env.go @@ -45,6 +45,9 @@ var ENV = struct { */ PORT string `env:"APP_PORT" envDefault:"8080"` AllowOrigins []string `env:"ALLOW_ORIGINS" envDefault:"http://localhost:3000,http://54.149.76.62"` + + EnableKafkaIntegration bool `env:"ENABLE_KAFKA_INTEGRATION" envDefault:false` + EnableRabbitMQIntegration bool `env:"ENABLE_AMQP_INTEGRATION" envDefault:false` }{} func init() { diff --git a/main.go b/main.go index 071c19f..784ec9f 100644 --- a/main.go +++ b/main.go @@ -19,8 +19,12 @@ func main() { os.Exit(0) } - listeners.AmqpStepResponseListener.Listen() - listeners.KafkaStepResponseListener.Listen() + if config.ENV.EnableKafkaIntegration { + listeners.AmqpStepResponseListener.Listen() + } + if config.ENV.EnableKafkaIntegration { + listeners.KafkaStepResponseListener.Listen() + } handlers.LoadHTTPRoutes() log.Println("Calling listener") } From c8df422ee25985c0a642c851a8ef829b3019d3cb Mon Sep 17 00:00:00 2001 From: Lohith KM Date: Wed, 28 Oct 2020 22:10:42 +0530 Subject: [PATCH 2/2] #68 | Correcting Enable RabbitMQ and Kakfa variable correctly in main.go and circle-ci file --- .circleci/config.yml | 2 +- main.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 58f453f..b3be2f7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -66,7 +66,7 @@ jobs: CLAMP_KAFKA_CONNECTION_STR: "localhost:9092" CLAMP_QUEUE_CONNECTION_STR: "amqp://guest:guest@localhost:5672/" ENABLE_KAFKA_INTEGRATION: true - EnableRabbitMQIntegration: true + ENABLE_AMQP_INTEGRATION: true command: | if [ $CIRCLE_BRANCH == 'master' ]; then ./cc-test-reporter before-build diff --git a/main.go b/main.go index 784ec9f..d64c912 100644 --- a/main.go +++ b/main.go @@ -19,7 +19,7 @@ func main() { os.Exit(0) } - if config.ENV.EnableKafkaIntegration { + if config.ENV.EnableRabbitMQIntegration { listeners.AmqpStepResponseListener.Listen() } if config.ENV.EnableKafkaIntegration {