EventService: Add retry configuration support

This commit is to pass configuration parameters: retry attempts,
retry interval secs and retry policy to http client and take
required delivery retry policy action.

Also, perform async wait for retryTimeoutInterval before each
retry attempts.

Tested:
- Set and verified config properties by sending PATCH req on
  EventService and EventDestination uri.
- Verified the appropriate delivery retry policy action block reached.
- Verified the async_wait logic by triggering retry case depending
  failed state of connection.
    - could see a wait for timeout interval before next retry.

Signed-off-by: Ayushi Smriti <smriti.ayushi@linux.intel.com>
Change-Id: Id1366fca59dc9e6543c553bfe5df95a59f468bc7
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
index c11e31b..7c96420 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -292,7 +292,8 @@
         host(inHost), port(inPort), path(inPath), uriProto(inUriProto)
     {
         conn = std::make_shared<crow::HttpClient>(
-            crow::connections::systemBus->get_io_context(), host, port, path);
+            crow::connections::systemBus->get_io_context(), id, host, port,
+            path);
     }
     ~Subscription()
     {}
@@ -444,6 +445,17 @@
         this->sendEvent(msg.dump());
     }
 
+    void updateRetryConfig(const uint32_t retryAttempts,
+                           const uint32_t retryTimeoutInterval)
+    {
+        conn->setRetryConfig(retryAttempts, retryTimeoutInterval);
+    }
+
+    void updateRetryPolicy()
+    {
+        conn->setRetryPolicy(retryPolicy);
+    }
+
   private:
     uint64_t eventSeqNum;
     std::string host;
@@ -677,6 +689,7 @@
     void setEventServiceConfig(const EventServiceConfig& cfg)
     {
         bool updateConfig = false;
+        bool updateRetryCfg = false;
 
         if (serviceEnabled != std::get<0>(cfg))
         {
@@ -696,18 +709,31 @@
         {
             retryAttempts = std::get<1>(cfg);
             updateConfig = true;
+            updateRetryCfg = true;
         }
 
         if (retryTimeoutInterval != std::get<2>(cfg))
         {
             retryTimeoutInterval = std::get<2>(cfg);
             updateConfig = true;
+            updateRetryCfg = true;
         }
 
         if (updateConfig)
         {
             updateSubscriptionData();
         }
+
+        if (updateRetryCfg)
+        {
+            // Update the changed retry config to all subscriptions
+            for (const auto& it :
+                 EventServiceManager::getInstance().subscriptionsMap)
+            {
+                std::shared_ptr<Subscription> entry = it.second;
+                entry->updateRetryConfig(retryAttempts, retryTimeoutInterval);
+            }
+        }
     }
 
     void updateNoOfSubscribersCount()
@@ -791,6 +817,10 @@
             cacheLastEventTimestamp();
         }
 #endif
+        // Update retry configuration.
+        subValue->updateRetryConfig(retryAttempts, retryTimeoutInterval);
+        subValue->updateRetryPolicy();
+
         return id;
     }
 
diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp
index b88cb43..ba1ea19 100644
--- a/redfish-core/lib/event_service.hpp
+++ b/redfish-core/lib/event_service.hpp
@@ -507,6 +507,7 @@
                 return;
             }
             subValue->retryPolicy = *retryPolicy;
+            subValue->updateRetryPolicy();
         }
 
         EventServiceManager::getInstance().updateSubscriptionData();