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

Improve fwdctl dump #764

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

Improve fwdctl dump #764

wants to merge 4 commits into from

Conversation

zdf1230
Copy link

@zdf1230 zdf1230 commented Dec 21, 2024

Purpose

This change is to address issue #348.

Detail

This added flags such as --start-key, --stop-key, --max-key-count and --output-format with csv, json as options and stdout as default behavior.

Test

Tested locally & unit tests added

@zdf1230 zdf1230 marked this pull request as ready for review December 21, 2024 07:15
Copy link
Collaborator

@rkuris rkuris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good! A few things we need before landing:

  • Error handling when writing is very important here. We can't drop IO errors, or we risk having a bad dump with no warning
  • Continuation has to support hash key values, not just text. If the next key is binary, the lossy UTF-8 inputs won't work correctly. Maybe we need start-key-hex?
  • Small bug in the stop key

Otherwise, this looks fantastic! Great test coverage!

The remaining comments are mostly style preferences and are not mandatory.

fwdctl/src/dump.rs Show resolved Hide resolved
fwdctl/src/dump.rs Outdated Show resolved Hide resolved
fwdctl/src/dump.rs Outdated Show resolved Hide resolved
fwdctl/src/dump.rs Outdated Show resolved Hide resolved
fwdctl/src/dump.rs Show resolved Hide resolved
fwdctl/src/dump.rs Outdated Show resolved Hide resolved

trait OutputHandler {
fn handle_record(&mut self, key: &[u8], value: &[u8]);
fn flush(&mut self);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I debated implementing flush as a Drop for those implementations that require it, but that limits your error handling to panic.

fwdctl/src/dump.rs Outdated Show resolved Hide resolved
fwdctl/src/dump.rs Show resolved Hide resolved
fwdctl/tests/cli.rs Show resolved Hide resolved
@zdf1230
Copy link
Author

zdf1230 commented Jan 14, 2025

This looks really good! A few things we need before landing:

  • Error handling when writing is very important here. We can't drop IO errors, or we risk having a bad dump with no warning
  • Continuation has to support hash key values, not just text. If the next key is binary, the lossy UTF-8 inputs won't work correctly. Maybe we need start-key-hex?
  • Small bug in the stop key

Otherwise, this looks fantastic! Great test coverage!

The remaining comments are mostly style preferences and are not mandatory.

Thanks for reviewing the code! I pushed some commits to improve. It should be ready to be reviewed now.

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.

2 participants