Skip to content

Commit

Permalink
implement defered loglet commit resolver (#1968)
Browse files Browse the repository at this point in the history
  • Loading branch information
muhamadazmy authored Sep 19, 2024
1 parent 8d16d9a commit ee1b745
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions crates/bifrost/src/loglet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,22 @@ pub trait LogletReadStream: Stream<Item = Result<LogEntry<LogletOffset>, Operati

pub type SendableLogletReadStream = Pin<Box<dyn LogletReadStream + Send>>;

#[allow(dead_code)]
pub(crate) struct LogletCommitResolver {
tx: oneshot::Sender<Result<LogletOffset, AppendError>>,
}

#[allow(dead_code)]
impl LogletCommitResolver {
pub fn sealed(self) {
let _ = self.tx.send(Err(AppendError::Sealed));
}

pub fn offset(self, offset: LogletOffset) {
let _ = self.tx.send(Ok(offset));
}
}

pub struct LogletCommit {
rx: oneshot::Receiver<Result<LogletOffset, AppendError>>,
}
Expand All @@ -170,6 +186,12 @@ impl LogletCommit {
let _ = tx.send(Ok(offset));
Self { rx }
}

#[allow(dead_code)]
pub(crate) fn deferred() -> (Self, LogletCommitResolver) {
let (tx, rx) = oneshot::channel();
(Self { rx }, LogletCommitResolver { tx })
}
}

impl std::future::Future for LogletCommit {
Expand Down

0 comments on commit ee1b745

Please sign in to comment.