-
Notifications
You must be signed in to change notification settings - Fork 614
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
Add surgery clear-page
command
#389
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not make it make it another command in
surgeon
?I imagine it exactly as a place to land this types of 'operations' and CLI should be free of deep business logic assumptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean command
surgery write-page
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we should put the logic within this file:
internal/surgeon/surgeon.go
So have there a method:
and call it from the CLI rather than move the WritePage method into guts_cli.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partially makes sense to me.
Added
ClearPage
in surgeon package. But I still think it makes more sense to get bothReadPage
andWritePage
in packageguts_cli
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both
ReadPage
andWritePage
are more low-level, and it'd better to put them inguts_cli
. WhileCopyPage
andClearPage
is relatively high-level as compared to ReadPage & WritePage, so it's OK to put them in surgeon package. .There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not proud of ReadPage & WritePage implementation to make them part of shared library.
They are very inefficient in generic usage scenario - i.e. they shouldn't be used to read/write multiple pages. For this reason (and their simplicity) I though about them as private (yes: should be lower case) part of surgeon - not something for a wider consumption in other use-cases.
Second idea is that some day guts_cli.go and page.go should get merged in a single file instead of 2 sibling implementations of the same data model. Thus I would prefer avoid further divergence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ptabor . This point totally makes sense to me. We need to refactor the design/implementation, of course in separate PRs.
Yes, I am thinking the same thing, I mean the behavior of reading/writing single or multiple pages. It should be fine for now because the implementation of
ReadPage
andWritePage
is Symmetrical. Both of them supporting operating multiple pages.The implementation of
gut_cli
package has too much overlap with the existingbbolt
package, we really need to merge them. It's the next next step we can do.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the
page.overflow > 0
, then it's dangerous to write only one of the pages. If we really need to do this, it definitely should be internal functions/methods. Let's investigate/do this separately.