Skip to content

Commit 89d0aa5

Browse files
committed
Loglet::enqueue_batch should return OperationError
1 parent 9cf2d2b commit 89d0aa5

File tree

6 files changed

+9
-16
lines changed

6 files changed

+9
-16
lines changed

crates/bifrost/src/loglet/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub trait Loglet: Send + Sync + std::fmt::Debug {
110110
/// retry failing appends indefinitely until the loglet is sealed. In that case, such commits
111111
/// might still appear to future readers but without returning the commit acknowledgement to
112112
/// the original writer.
113-
async fn enqueue_batch(&self, payloads: Arc<[Record]>) -> Result<LogletCommit, ShutdownError>;
113+
async fn enqueue_batch(&self, payloads: Arc<[Record]>) -> Result<LogletCommit, OperationError>;
114114

115115
/// The tail is *the first unwritten position* in the loglet.
116116
///

crates/bifrost/src/loglet_wrapper.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use std::sync::Arc;
1616
use futures::{Stream, StreamExt};
1717
use tracing::instrument;
1818

19-
use restate_core::ShutdownError;
2019
use restate_types::logs::metadata::SegmentIndex;
2120
use restate_types::logs::{KeyFilter, LogletOffset, Lsn, SequenceNumber};
2221
use restate_types::logs::{Record, TailState};
@@ -140,10 +139,7 @@ impl LogletWrapper {
140139
#[allow(unused)]
141140
#[cfg(any(test, feature = "test-util"))]
142141
pub async fn append(&self, payload: Record) -> Result<Lsn, AppendError> {
143-
let commit = self
144-
.enqueue_batch(Arc::new([payload]))
145-
.await
146-
.map_err(AppendError::Shutdown)?;
142+
let commit = self.enqueue_batch(Arc::new([payload])).await?;
147143
commit.await
148144
}
149145

@@ -166,13 +162,10 @@ impl LogletWrapper {
166162
)
167163
)]
168164
pub async fn append_batch(&self, payloads: Arc<[Record]>) -> Result<Lsn, AppendError> {
169-
self.enqueue_batch(payloads)
170-
.await
171-
.map_err(AppendError::Shutdown)?
172-
.await
165+
self.enqueue_batch(payloads).await?.await
173166
}
174167

175-
pub async fn enqueue_batch(&self, payloads: Arc<[Record]>) -> Result<Commit, ShutdownError> {
168+
pub async fn enqueue_batch(&self, payloads: Arc<[Record]>) -> Result<Commit, OperationError> {
176169
if self.tail_lsn.is_some() {
177170
return Ok(Commit::sealed());
178171
}

crates/bifrost/src/providers/local_loglet/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl Loglet for LocalLoglet {
136136
Box::pin(self.tail_watch.to_stream())
137137
}
138138

139-
async fn enqueue_batch(&self, payloads: Arc<[Record]>) -> Result<LogletCommit, ShutdownError> {
139+
async fn enqueue_batch(&self, payloads: Arc<[Record]>) -> Result<LogletCommit, OperationError> {
140140
// NOTE: This implementation doesn't perform pipelined writes yet. This will block the caller
141141
// while the underlying write is in progress and only return the Commit future as resolved.
142142
// This is temporary until pipelined writes are fully supported.

crates/bifrost/src/providers/memory_loglet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ impl Loglet for MemoryLoglet {
325325
Box::pin(self.tail_watch.to_stream())
326326
}
327327

328-
async fn enqueue_batch(&self, payloads: Arc<[Record]>) -> Result<LogletCommit, ShutdownError> {
328+
async fn enqueue_batch(&self, payloads: Arc<[Record]>) -> Result<LogletCommit, OperationError> {
329329
let mut log = self.log.lock().unwrap();
330330
if self.sealed.load(Ordering::Relaxed) {
331331
return Ok(LogletCommit::sealed());

crates/bifrost/src/providers/replicated_loglet/loglet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl<T: TransportConnect> Loglet for ReplicatedLoglet<T> {
140140
Box::pin(self.known_global_tail.to_stream())
141141
}
142142

143-
async fn enqueue_batch(&self, payloads: Arc<[Record]>) -> Result<LogletCommit, ShutdownError> {
143+
async fn enqueue_batch(&self, payloads: Arc<[Record]>) -> Result<LogletCommit, OperationError> {
144144
match self.sequencer {
145145
SequencerAccess::Local { ref handle } => handle.enqueue_batch(payloads).await,
146146
SequencerAccess::Remote { .. } => {

crates/bifrost/src/providers/replicated_loglet/sequencer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use super::{
3232
record_cache::RecordCache,
3333
replication::spread_selector::{SelectorStrategy, SpreadSelector},
3434
};
35-
use crate::loglet::{util::TailOffsetWatch, LogletCommit};
35+
use crate::loglet::{util::TailOffsetWatch, LogletCommit, OperationError};
3636
use appender::SequencerAppender;
3737

3838
#[derive(thiserror::Error, Debug)]
@@ -160,7 +160,7 @@ impl<T: TransportConnect> Sequencer<T> {
160160
pub async fn enqueue_batch(
161161
&self,
162162
payloads: Arc<[Record]>,
163-
) -> Result<LogletCommit, ShutdownError> {
163+
) -> Result<LogletCommit, OperationError> {
164164
if self
165165
.sequencer_shared_state
166166
.global_committed_tail()

0 commit comments

Comments
 (0)