Skip to content

Commit

Permalink
Add config check for LeaseBased read only option
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoverbear committed Nov 14, 2018
1 parent 0bf51e4 commit 9fb5329
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ pub struct Config {
pub max_election_tick: usize,

/// Choose the linearizability mode or the lease mode to read data. If you don’t care about the read consistency and want a higher read performance, you can use the lease mode.
///
/// Setting this to `LeaseBased` requires `check_quorum = true`.
pub read_only_option: ReadOnlyOption,

/// Don't broadcast an empty raft entry to notify follower to commit an entry.
Expand Down Expand Up @@ -204,6 +206,12 @@ impl Config {
));
}

if self.read_only_option == ReadOnlyOption::LeaseBased && !self.check_quorum {
return Err(Error::ConfigInvalid(
"read_only_option == LeaseBased requires check_quorum == true".into(),
));
}

Ok(())
}
}

0 comments on commit 9fb5329

Please sign in to comment.