Skip to content

Commit

Permalink
Include more docs on Quorum and bump patch version
Browse files Browse the repository at this point in the history
  • Loading branch information
rcmgleite committed Jun 5, 2024
1 parent d23fdd7 commit fb0cbf2
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rldb"
version = "0.1.3"
version = "0.1.4"
edition = "2021"
description = "A dynamo-like key/value database written in rust"
authors = ["Rafael Leite"]
Expand Down
3 changes: 3 additions & 0 deletions src/cluster/quorum/min_required_replicas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ pub struct MinRequiredReplicas<T, E> {

impl<T, E> MinRequiredReplicas<T, E> {
/// Constructs a new instance of [`MinRequiredReplicas`]
///
/// # Error
/// This function returns an error if the provided `n_replicas` arugment is less than `required_successes`
pub fn new(n_replicas: usize, required_successes: usize) -> Result<Self> {
if n_replicas < required_successes {
return Err(Error::Logic {
Expand Down
4 changes: 4 additions & 0 deletions src/cluster/quorum/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ pub enum Evaluation {
Unreachable,
}

/// The result of a [`Quorum::finish`] call
#[derive(Debug)]
pub struct QuorumResult<T, E> {
/// The quorum evaluation - see [`Evaluation`]
pub evaluation: Evaluation,
/// successful items
pub successes: Vec<T>,
/// failed items
pub failures: Vec<E>,
}

Expand Down
5 changes: 5 additions & 0 deletions src/cmd/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ impl Get {

// TODO: we are waiting for all nodes on the preference list to return either error or success
// this will cause latency issues and it's no necessary.. fix it later
// Note: The [`crate::cluster::quorum::Quorum`] API already handles early evaluation
// in case quorum is not reachable. The change to needed here is fairly small in this regard.
// What's missing is deciding on:
// 1. what do we do with inflight requests in case of an early success?
// 2. (only for the PUT case) what do we do with successful PUT requests? rollback? what does that look like?
while let Some(res) = futures.next().await {
match res {
Ok(res) => {
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/put.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ impl Put {
// for now, let's wait til all futures either succeed or fail.
// we don't strictly need that since we are quorum based..
// doing it this way now for simplicity but this will have a latency impact
//
// For more info, see similar comment on [`crate::cmd::get::Get`]
while let Some(res) = futures.next().await {
match res {
Ok(_) => {
Expand Down

0 comments on commit fb0cbf2

Please sign in to comment.