Skip to content

Refactor Queue Handling in segment_destination.dart #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

neelkanth-kaushik
Copy link
Contributor

@neelkanth-kaushik neelkanth-kaushik commented May 23, 2025

Context: The original sendEvents function dequeued all events after each batch attempt, regardless of whether the batch was successfully sent or not. This led to failed events being prematurely removed from the queue, preventing retry on subsequent flush attempts.

Fix:

  1. Updated the logic to only add batches to sentEvents if they are successfully sent.
  2. Moved the call to _queuePlugin.dequeue(sentEvents) outside the batch loop, ensuring that only the successfully sent events are dequeued once, after all batch attempts have completed.
  3. This change ensures failed events remain in the queue and are available for retry on the next flush attempt, which aligns with the expected behavior outlined in the issue.

Impact: More reliable event delivery. Failed events will no longer be silently dropped and will be retried as intended, improving data integrity and consistency.

This Pull Request contains the changes suggested in following Pull Requests:

  1. Fix: Prevent failed events from being dequeued #140
  2. Refactor: Move dequeue outside loop for efficiency #142

@neelkanth-kaushik neelkanth-kaushik self-assigned this May 23, 2025
@neelkanth-kaushik neelkanth-kaushik changed the title Refactor Dequeue Handling Operation in segment_destination.dart Refactor Queue Handling in segment_destination.dart May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant