(cobra bots) add a --heartbeat_timeout option to specify when the bot should terminate because no events are received
This commit is contained in:
		| @@ -22,6 +22,7 @@ namespace ix | ||||
|                           const std::string& filter, | ||||
|                           const std::string& position, | ||||
|                           bool enableHeartbeat, | ||||
|                           int heartBeatTimeout, | ||||
|                           int runtime) | ||||
|     { | ||||
|         ix::CobraConnection conn; | ||||
| @@ -78,7 +79,7 @@ namespace ix | ||||
|  | ||||
|         std::thread t1(timer); | ||||
|  | ||||
|         auto heartbeat = [&sentCount, &receivedCount, &stop, &enableHeartbeat] { | ||||
|         auto heartbeat = [&sentCount, &receivedCount, &stop, &enableHeartbeat, &heartBeatTimeout] { | ||||
|             std::string state("na"); | ||||
|  | ||||
|             if (!enableHeartbeat) return; | ||||
| @@ -94,11 +95,12 @@ namespace ix | ||||
|                 if (currentState == state) | ||||
|                 { | ||||
|                     CoreLogger::error("no messages received or sent for 1 minute, exiting"); | ||||
|                     exit(1); | ||||
|                     fatalCobraError = true; | ||||
|                     break; | ||||
|                 } | ||||
|                 state = currentState; | ||||
|  | ||||
|                 auto duration = std::chrono::minutes(1); | ||||
|                 auto duration = std::chrono::seconds(heartBeatTimeout); | ||||
|                 std::this_thread::sleep_for(duration); | ||||
|             } | ||||
|  | ||||
|   | ||||
| @@ -30,6 +30,7 @@ namespace ix | ||||
|                     const std::string& filter, | ||||
|                     const std::string& position, | ||||
|                     bool enableHeartbeat, | ||||
|                     int heartBeatTimeout, | ||||
|                     int runtime); | ||||
|  | ||||
|         void setOnBotMessageCallback(const OnBotMessageCallback& callback); | ||||
|   | ||||
| @@ -23,6 +23,7 @@ namespace ix | ||||
|                                 SentryClient& sentryClient, | ||||
|                                 bool verbose, | ||||
|                                 bool enableHeartbeat, | ||||
|                                 int heartBeatTimeout, | ||||
|                                 int runtime) | ||||
|     { | ||||
|         CobraBot bot; | ||||
| @@ -81,6 +82,7 @@ namespace ix | ||||
|                        filter, | ||||
|                        position, | ||||
|                        enableHeartbeat, | ||||
|                        heartBeatTimeout, | ||||
|                        runtime); | ||||
|     } | ||||
| } // namespace ix | ||||
|   | ||||
| @@ -19,5 +19,6 @@ namespace ix | ||||
|                                 SentryClient& sentryClient, | ||||
|                                 bool verbose, | ||||
|                                 bool enableHeartbeat, | ||||
|                                 int heartBeatTimeout, | ||||
|                                 int runtime); | ||||
| } // namespace ix | ||||
|   | ||||
| @@ -63,6 +63,7 @@ namespace ix | ||||
|                                 const std::string& timer, | ||||
|                                 bool verbose, | ||||
|                                 bool enableHeartbeat, | ||||
|                                 int heartBeatTimeout, | ||||
|                                 int runtime) | ||||
|     { | ||||
|         ix::CobraConnection conn; | ||||
| @@ -146,6 +147,7 @@ namespace ix | ||||
|                        filter, | ||||
|                        position, | ||||
|                        enableHeartbeat, | ||||
|                        heartBeatTimeout, | ||||
|                        runtime); | ||||
|     } | ||||
| } // namespace ix | ||||
|   | ||||
| @@ -23,5 +23,6 @@ namespace ix | ||||
|                                 const std::string& timer, | ||||
|                                 bool verbose, | ||||
|                                 bool enableHeartbeat, | ||||
|                                 int heartBeatTimeout, | ||||
|                                 int runtime); | ||||
| } // namespace ix | ||||
|   | ||||
| @@ -70,6 +70,7 @@ namespace ix | ||||
|                                 bool fluentd, | ||||
|                                 bool quiet, | ||||
|                                 bool enableHeartbeat, | ||||
|                                 int heartBeatTimeout, | ||||
|                                 int runtime) | ||||
|     { | ||||
|         CobraBot bot; | ||||
| @@ -93,6 +94,7 @@ namespace ix | ||||
|                        filter, | ||||
|                        position, | ||||
|                        enableHeartbeat, | ||||
|                        heartBeatTimeout, | ||||
|                        runtime); | ||||
|     } | ||||
| } // namespace ix | ||||
|   | ||||
| @@ -19,5 +19,6 @@ namespace ix | ||||
|                                 bool fluentd, | ||||
|                                 bool quiet, | ||||
|                                 bool enableHeartbeat, | ||||
|                                 int heartBeatTimeout, | ||||
|                                 int runtime); | ||||
| } // namespace ix | ||||
|   | ||||
		Reference in New Issue
	
	Block a user