[VOL-1862] rwCore waits for kafka and KV Store

This commit is a cherry pick into the master branch from the
voltha 2.1 branch of patch https://gerrit.opencord.org/#/c/15030/

Change-Id: I8a306c8b37ad700ef8234466919e0604e14787cd
diff --git a/rw_core/config/config.go b/rw_core/config/config.go
index 41d96f4..133b1a4 100644
--- a/rw_core/config/config.go
+++ b/rw_core/config/config.go
@@ -52,6 +52,8 @@
 	default_CoreTimeout               = int64(500)
 	default_CoreBindingKey            = "voltha_backend_name"
 	default_CorePairTopic             = "rwcore_1"
+	default_MaxConnectionRetries      = -1 // retries forever
+	default_ConnectionRetryInterval   = 2  // in seconds
 )
 
 // RWCoreFlags represents the set of configurations used by the read-write core service
@@ -84,6 +86,8 @@
 	DefaultCoreTimeout        int64
 	CoreBindingKey            string
 	CorePairTopic             string
+	MaxConnectionRetries      int
+	ConnectionRetryInterval   int
 }
 
 func init() {
@@ -120,6 +124,8 @@
 		DefaultCoreTimeout:        default_CoreTimeout,
 		CoreBindingKey:            default_CoreBindingKey,
 		CorePairTopic:             default_CorePairTopic,
+		MaxConnectionRetries:      default_MaxConnectionRetries,
+		ConnectionRetryInterval:   default_ConnectionRetryInterval,
 	}
 	return &rwCoreFlag
 }
@@ -201,5 +207,11 @@
 	help = fmt.Sprintf("Core pairing group topic")
 	flag.StringVar(&cf.CorePairTopic, "core_pair_topic", default_CorePairTopic, help)
 
+	help = fmt.Sprintf("The number of retries to connect to a dependent component")
+	flag.IntVar(&(cf.MaxConnectionRetries), "max_connection_retries", default_MaxConnectionRetries, help)
+
+	help = fmt.Sprintf("The number of seconds between each connection retry attempt ")
+	flag.IntVar(&(cf.ConnectionRetryInterval), "connection_retry_interval", default_ConnectionRetryInterval, help)
+
 	flag.Parse()
 }