-
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
Require documentation on public interfaces #87
Conversation
622325c
to
3dea091
Compare
@@ -224,6 +225,8 @@ extern crate protobuf; | |||
extern crate quick_error; | |||
extern crate rand; | |||
|
|||
/// This module supplies the needed message types. However, it is autogenerated and thus cannot be |
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 we could examine having the generated code use comments from the proto files as well. 🤔
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.
That would be really cool!
src/log_unstable.rs
Outdated
@@ -148,6 +166,8 @@ impl Unstable { | |||
&self.entries[l - off..h - off] | |||
} | |||
|
|||
/// Asserts the hi and lo values against each other and against the |
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.
Can you throw hi
and lo
in ticks so they're formatted distinctly?
pub fn iter_mut(&mut self) -> Chain<IterMut<u64, Progress>, IterMut<u64, Progress>> { | ||
self.voters.iter_mut().chain(&mut self.learners) | ||
} | ||
|
||
/// Adds a voter node | ||
/// | ||
/// # Panics |
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.
This can be avoided. :) Thanks: #88
pub fn remove(&mut self, id: u64) -> Option<Progress> { | ||
match self.voters.remove(&id) { | ||
None => self.learners.remove(&id), | ||
some => some, | ||
} | ||
} | ||
|
||
/// Promote a learner to a peer. | ||
/// | ||
/// # Panics |
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.
src/raft.rs
Outdated
Leader, | ||
/// The node could become a candidate. |
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.
Please add a note that this only happens if prevote
is enabled.
src/raft.rs
Outdated
@@ -753,6 +794,8 @@ impl<T: Storage> Raft<T> { | |||
} | |||
} | |||
|
|||
/// Appends an slice of entries to the log. The entries are updated to match |
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.
Appends a slice
// All fields in Ready are read-only. | ||
/// Ready encapsulates the entries and messages that are ready to read, | ||
/// be saved to stable storage, committed or sent to other peers. | ||
/// All fields in Ready are read-only. |
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.
src/status.rs
Outdated
pub hs: HardState, | ||
/// The softstate of the raft, representing prosposed state. |
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.
proposed
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 notice that there is consistency issues between some comments (no capital at the start.
) and the new ones (Capital at the start.
).
Would you be willing to fix them to all be one style at least for this diff? (`Capital at the front works for me.) If not I can follow up.
PTAL @queenypingcap |
3dea091
to
6804476
Compare
@Hoverbear PTAL |
6804476
to
a20eff4
Compare
proto/eraftpb.proto
Outdated
@@ -6,6 +6,16 @@ enum EntryType { | |||
EntryConfChange = 1; | |||
} | |||
|
|||
// The entry is a type of change that needs to be applied. It contains two data fields. | |||
// Which field is used and how can be determined by the entry type. |
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.
-> Which field is used and how it can be determined by the entry type.
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 it should be:
Which field is used, and how, is determined by the entry type.
The usage and how it's used is determined by the type. I'm rewording it completely though to see if I can make it more obvious.
While the fields are built into the model; their usage is determined by the entry_type.
src/progress.rs
Outdated
/// an optimized state for fast replicating log entries to the follower. | ||
/// | ||
/// When in ProgressStateSnapshot, leader should have sent out snapshot | ||
/// before and stops sending any replication 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.
stops -> stop
src/progress.rs
Outdated
@@ -200,28 +233,31 @@ impl Progress { | |||
} | |||
} | |||
|
|||
/// Changes the progress to a a Replicate. |
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.
Changes the progress to a Replicate.
src/progress.rs
Outdated
pub fn optimistic_update(&mut self, n: u64) { | ||
self.next_idx = n + 1; | ||
} | ||
|
||
// maybe_decr_to returns false if the given to index comes from an out of order message. | ||
// Otherwise it decreases the progress next index to min(rejected, last) and returns true. | ||
/// Returns false if the given to index comes from an out of order 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.
-> Returns false if the given index comes from an out of order message. ?
src/raft.rs
Outdated
@@ -444,38 +472,45 @@ impl<T: Storage> Raft<T> { | |||
r | |||
} | |||
|
|||
/// Grabs a immutable reference to the store. |
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.
a -> an
src/raft.rs
Outdated
@@ -2060,6 +2132,7 @@ impl<T: Storage> Raft<T> { | |||
self.election_elapsed >= self.randomized_election_timeout | |||
} | |||
|
|||
/// Regenerates and stroes the election timeout. |
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.
stroes -> stores
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.
Good eye!
src/raft_log.rs
Outdated
/// It returns the first index of conflicting entries between the existing | ||
/// entries and the given entries, if there are any. | ||
/// | ||
/// If there is no conflicting entries, and the existing entries contain |
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 there are no conflicting entries, and the existing entries contain...
src/raft_log.rs
Outdated
/// If there is no conflicting entries, and the existing entries contain | ||
/// all the given entries, zero will be returned. | ||
/// | ||
/// If there is no conflicting entries, but the given entries contains new |
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 there are no conflicting entries, but the given entries contain new...
src/raw_node.rs
Outdated
// Returns true to indicate that there will probably be some readiness need to be handled. | ||
/// Tick advances the internal logical clock by a single tick. | ||
/// | ||
/// Returns true to indicate that there will probably be some readiness need to be handled. |
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.
Returns true to indicate that there will probably be some readiness which need to be handled.
src/raw_node.rs
Outdated
/// ReadIndex requests a read state. The read state will be set in ready. | ||
/// Read State has a read index. Once the application advances further than the read | ||
/// index, any linearizable read requests issued before the read request can be | ||
/// processed safely. The read state will have the same rctx attched. |
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.
attched -> attached
a20eff4
to
f26ba85
Compare
@CaitinChen Thank you for the thorough review! PTAL |
Previously, compiling would not warn or error for lack of documentation. Now the compiler will fail if public interfaces are left without documentation. To prevent the library from failing, all public interfaces have been documented. resolves tikv#72
f26ba85
to
8772e69
Compare
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.
Thank you for this valuable contribution. 🙇♀️ :
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.
LGTM
Previously, compiling would not warn or error for lack of documentation.
Now the compiler will fail if public interfaces are left without
documentation. To prevent the library from failing, all public
interfaces have been documented.
resolves #72
Critique welcome: I tried to document the functions as I understood them but there
may be places where I have typos or misunderstood.
I also noticed that some of these functions should probably be scoped to the crate instead of
making them public. I did not change them, however, as that would potentially break the interface.
Could you let me know if any of these functions can be converted to
pub(crate)
?