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

RaftStorage: add method get_log_state() -> Result<(Option<LogId>, Option<LogId>, StorageError> to return the first and last log id in the store #61

Closed
Tracked by #39
drmingdrmer opened this issue Jan 4, 2022 · 9 comments · Fixed by #81
Assignees
Labels
A-store Area: storage good first issue Good for newcomers

Comments

@drmingdrmer
Copy link
Member

drmingdrmer commented Jan 4, 2022

RaftStorage: add method get_log_state() -> Result<(Option<LogId>, Option<LogId>, StorageError> to return the first and last log id in the store.

Then remove first_id_in_log() and last_id_in_log().

This way to simplify the trait API users need to impl.

async fn first_id_in_log(&self) -> Result<Option<LogId>, StorageError>;
async fn first_known_log_id(&self) -> Result<LogId, StorageError>;
/// Returns the last log id in log.
///
/// The impl should not consider the applied log id in state machine.
async fn last_id_in_log(&self) -> Result<LogId, StorageError>;

@github-actions
Copy link

github-actions bot commented Jan 4, 2022

👋 Thanks for opening this issue!

Get help or engage by:

  • /help : to print help messages.
  • /assignme : to assign this issue to you.

@drmingdrmer drmingdrmer changed the title RaftStorage: add method log_state() -> Result<(Option<LogId>, Option<LogId>, StorageError> to return the first and last log id in the store RaftStorage: add method get_log_state() -> Result<(Option<LogId>, Option<LogId>, StorageError> to return the first and last log id in the store Jan 4, 2022
@drmingdrmer drmingdrmer added good first issue Good for newcomers A-store Area: storage labels Jan 4, 2022
@YangKian
Copy link
Contributor

YangKian commented Jan 4, 2022

/assignme

@YangKian
Copy link
Contributor

YangKian commented Jan 5, 2022

Hi, I have a question, the old last_id_in_log method will return a LogId,not an Option<LogId>, but the new one we should return an Option. I found I need to call unwrap_or_default() every time I want to get the last_log_id. Shall we replace the return type of get_log_state method to Result<(Option<LogId>, LogId), StorageError> ? @drmingdrmer

@drmingdrmer
Copy link
Member Author

There are some corner cases with using LogId for last_log_id.
E.g., when there is no log at all, using LogId, it returns (0,0), which will confuse the caller.

@YangKian
Copy link
Contributor

YangKian commented Jan 6, 2022

get~ thanks XD

@Veeupup
Copy link
Contributor

Veeupup commented Jan 6, 2022

@YangKian hi, this issue may have a strong connection with #49 , it seems difficult to finish each one alone, so do you want to combine these two issues into one pr to fix them or any other advice?

@YangKian
Copy link
Contributor

YangKian commented Jan 6, 2022

@Veeupup Sorry for the late reply. Is it blocking something on your side? It seems to be working fine on my side, at least the tests passed after the changes were made, if I'm not missing something. I'll fill the pr later, and if my side is blocking your progress, it's ok to leave it to me XD

@Veeupup
Copy link
Contributor

Veeupup commented Jan 6, 2022

@YangKian yeah, u can finish it later. from my side, it will make nonsense if last_id_in_log() and some function return LogId ranther than Option<LogId>.

@YangKian
Copy link
Contributor

YangKian commented Jan 6, 2022

@Veeupup Ok, let me handle it~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-store Area: storage good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants