File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -167,10 +167,17 @@ private function addToBuffer(array $record)
167167 private function flushBuffer ()
168168 {
169169 if (!empty ($ this ->buffer )) {
170- // send items
171- $ this ->send ($ this ->buffer );
170+ // send items, retry once with a fresh sequence token
171+ try {
172+ $ this ->send ($ this ->buffer );
173+ } catch (\Aws \CloudWatchLogs \Exception \CloudWatchLogsException $ e ) {
174+ $ this ->refreshSequenceToken ();
175+ $ this ->send ($ this ->buffer );
176+ }
177+
172178 // clear buffer
173179 $ this ->buffer = [];
180+
174181 // clear data amount
175182 $ this ->currentDataAmount = 0 ;
176183 }
@@ -240,6 +247,9 @@ private function formatRecords(array $entry)
240247 * - A batch of log events in a single request cannot span more than 24 hours. Otherwise, the operation fails.
241248 *
242249 * @param array $entries
250+ *
251+ * @throws \Aws\CloudWatchLogs\Exception\CloudWatchLogsException Thrown by putLogEvents for example in case of an
252+ * invalid sequence token
243253 */
244254 private function send (array $ entries )
245255 {
@@ -305,6 +315,13 @@ function ($group) {
305315 }
306316 }
307317
318+ $ this ->refreshSequenceToken ();
319+
320+ $ this ->initialized = true ;
321+ }
322+
323+ private function refreshSequenceToken ()
324+ {
308325 // fetch existing streams
309326 $ existingStreams =
310327 $ this
You can’t perform that action at this time.
0 commit comments