(ws cobra to statsd and sentry sender) exit if no messages are received for one minute, which is a sign that something goes wrong on the server side. That should be changed to be configurable in the future
This commit is contained in:
		@@ -153,6 +153,31 @@ namespace ix
 | 
			
		||||
 | 
			
		||||
        std::thread t1(timer);
 | 
			
		||||
 | 
			
		||||
        auto heartbeat = [&sentCount, &receivedCount] {
 | 
			
		||||
            std::string state("na");
 | 
			
		||||
 | 
			
		||||
            while (true)
 | 
			
		||||
            {
 | 
			
		||||
                std::stringstream ss;
 | 
			
		||||
                ss << "messages received " << receivedCount;
 | 
			
		||||
                ss << "messages sent " << sentCount;
 | 
			
		||||
 | 
			
		||||
                std::string currentState = ss.str();
 | 
			
		||||
 | 
			
		||||
                if (currentState == state)
 | 
			
		||||
                {
 | 
			
		||||
                    spdlog::error("no messages received or sent for 1 minute, exiting");
 | 
			
		||||
                    exit(1);
 | 
			
		||||
                }
 | 
			
		||||
                state = currentState;
 | 
			
		||||
 | 
			
		||||
                auto duration = std::chrono::minutes(1);
 | 
			
		||||
                std::this_thread::sleep_for(duration);
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        std::thread t2(heartbeat);
 | 
			
		||||
 | 
			
		||||
        auto statsdSender = [&queueManager, &host, &port, &sentCount, &tokens, &prefix, &stop] {
 | 
			
		||||
            // statsd client
 | 
			
		||||
            // test with netcat as a server: `nc -ul 8125`
 | 
			
		||||
@@ -184,7 +209,7 @@ namespace ix
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        std::thread t2(statsdSender);
 | 
			
		||||
        std::thread t3(statsdSender);
 | 
			
		||||
 | 
			
		||||
        conn.setEventCallback(
 | 
			
		||||
            [&conn, &channel, &filter, &jsonWriter, verbose, &queueManager, &receivedCount](
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user