Pause is equivalent to Stop, but with HA capabilities to resume at runtime. */
| 108 | |
| 109 | /* Pause is equivalent to Stop, but with HA capabilities to resume at runtime. */ |
| 110 | void GelfWriter::Pause() |
| 111 | { |
| 112 | m_HandleCheckResults.disconnect(); |
| 113 | m_HandleNotifications.disconnect(); |
| 114 | m_HandleStateChanges.disconnect(); |
| 115 | |
| 116 | m_ReconnectTimer->Stop(true); |
| 117 | |
| 118 | m_WorkQueue.Enqueue([this]() { |
| 119 | try { |
| 120 | ReconnectInternal(); |
| 121 | } catch (const std::exception&) { |
| 122 | Log(LogInformation, "GelfWriter") |
| 123 | << "Unable to connect, not flushing buffers. Data may be lost."; |
| 124 | } |
| 125 | }, PriorityImmediate); |
| 126 | |
| 127 | m_WorkQueue.Enqueue([this]() { DisconnectInternal(); }, PriorityLow); |
| 128 | m_WorkQueue.Join(); |
| 129 | |
| 130 | Log(LogInformation, "GelfWriter") |
| 131 | << "'" << GetName() << "' paused."; |
| 132 | |
| 133 | ObjectImpl<GelfWriter>::Pause(); |
| 134 | } |
| 135 | |
| 136 | void GelfWriter::AssertOnWorkQueue() |
| 137 | { |