Skip to content

Commit

Permalink
Remove anyhow::Error from append_envelope_to_bifrost helper
Browse files Browse the repository at this point in the history
  • Loading branch information
tillrohrmann committed Mar 6, 2024
1 parent 31f2250 commit d1d9f87
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion crates/ingress-dispatcher/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ impl Service {
new_pipe_target(
(),
|_, envelope| async {
append_envelope_to_bifrost(&mut bifrost.clone(), envelope).await
append_envelope_to_bifrost(&mut bifrost.clone(), envelope)
.await
.map_err(Into::into)
},
"bifrost output",
),
Expand Down
14 changes: 12 additions & 2 deletions crates/wal-protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::effects::BuiltinServiceEffects;
use crate::timer::TimerValue;
use restate_types::dedup::DedupInformation;
use restate_types::logs::{LogId, Payload};
use restate_types::partition_table::FindPartition;
use restate_types::partition_table::{FindPartition, PartitionTableError};
use restate_types::{GenerationalNodeId, PlainNodeId};

pub mod control;
Expand Down Expand Up @@ -150,6 +150,16 @@ impl WithPartitionKey for Envelope {
}
}

#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("partition not found: {0}")]
PartitionNotFound(#[from] PartitionTableError),
#[error("failed encoding envelope: {0}")]
Encode(#[from] bincode::error::EncodeError),
#[error("failed writing to bifrost: {0}")]
Bifrost(#[from] restate_bifrost::Error),
}

/// Appends the given envelope to the provided Bifrost instance. The log instance is chosen
/// based on the envelopes partition key.
///
Expand All @@ -158,7 +168,7 @@ impl WithPartitionKey for Envelope {
pub async fn append_envelope_to_bifrost(
bifrost: &mut Bifrost,
envelope: Envelope,
) -> Result<(), anyhow::Error> {
) -> Result<(), Error> {
let partition_id = metadata()
.partition_table()
.find_partition_id(envelope.partition_key())?;
Expand Down

0 comments on commit d1d9f87

Please sign in to comment.