-
Notifications
You must be signed in to change notification settings - Fork 409
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
refactor(Ready): add pub getters and make fields private #120
Conversation
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.
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.
It looks very expensive to maintain a read-only ready. And what if users want to advance ready partially?
src/raw_node.rs
Outdated
/// store/state-machine. These have previously been committed to stable | ||
/// store. | ||
#[inline] | ||
pub fn committed_entries(&self) -> Option<&[Entry]> { |
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.
So users have to clone the memory to handle committed entries in other thread now?
src/raw_node.rs
Outdated
/// If it contains a MsgSnap message, the application MUST report back to raft | ||
/// when the snapshot has been received or has failed by calling ReportSnapshot. | ||
#[inline] | ||
pub fn messages(&self) -> &[Message] { |
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.
Channel usually move the message. So a clone seems unavoidable.
@siddontang @BusyJay I don't have a clear enough understanding of this scenario, @Hoverbear, as the issue owner, what do you think about this? |
Thanks for taking up the flag on this @Ryan-Git. :) We will definitely need to include this in a non-patch version since it's an API break. I think @BusyJay has a very interesting point:
@BusyJay, could you expand more on this? I was unaware of this use. |
For example, we may handle committed entries and entries differently so may not advance them all together. Maybe we need a more clear |
@BusyJay Maybe we should revert the change on these particular fields, and merge this PR, then investigate how to move forward with this solution in another issue? |
I could revert changes on messages and committed_entries mentioned above. |
@Ryan-Git Yeah, let's revert them for now. Thanks so much! |
updated |
PTAL @BusyJay |
tests/cases/test_raw_node.rs
Outdated
@@ -59,21 +59,22 @@ fn conf_change(t: ConfChangeType, node_id: u64) -> ConfChange { | |||
cc | |||
} | |||
|
|||
fn new_ready( |
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.
Maybe we can #[derive(PartialEq)]
instead?
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.
Does it mean to add a pub constructor? Otherwise we can't make a Ready from the private fields.
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.
Ah, nevermind. :)
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.
emm.. do you mean to add the constructor or just keep it as it is?
LGTM. Please resolves conflicts. |
resolved |
bors r+ |
@Ryan-Git Thanks, I'm going to drive this to merge. :) I decided to use your PR to test our bors and I have a small hiccup. If you get some notifications you can just ignore them. Sorry about that! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bors r+ |
@Hoverbear My pleasure :-) |
Fixes #90