Skip to content
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

feat: update the messenger kafka commit frequency #106

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions packages/talos_messenger_core/src/services/inbound_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,28 @@ where
Ok(is_completed) if is_completed => {
self.suffix.set_item_state(version, SuffixItemState::Complete(reason));

// Pruning of suffix.
self.suffix.update_prune_index_from_version(version);
// Update the prune index in suffix if applicable.
let prune_index = self.suffix.update_prune_index_from_version(version);

// If there is a prune_index, it is safe to assume, all messages prioir to this are decided + on_commit actions are actioned.
// Therefore, it is safe to commit till that offset/version.
if let Some(index) = prune_index {
let prune_item_option = self.suffix.messages.get(index);

if let Some(Some(prune_item)) = prune_item_option {
let commit_offset = prune_item.item_ver + 1;
debug!("[Commit] Updating tpl to version .. {commit_offset}");
let _ = self.message_receiver.update_offset_to_commit(commit_offset as i64);

self.message_receiver.commit_async();
}
}

debug!("[Actions] All actions for version {version} completed!");
// Check prune eligibility by looking at the prune meta info.
if let Some(index_to_prune) = self.suffix.get_safe_prune_index() {
// Call prune method on suffix.
let _ = self.suffix.prune_till_index(index_to_prune);

// let commit_offset = version + 1;
// debug!("[Commit] Updating tpl to version .. {commit_offset}");
// let _ = self.message_receiver.update_offset_to_commit(commit_offset as i64);

// self.message_receiver.commit_async();
}
}
_ => {}
Expand Down
Loading