Skip to content

Commit

Permalink
Remove type EntryResultOrEmpty, as it's the same type as CompletionRe…
Browse files Browse the repository at this point in the history
…sult
  • Loading branch information
slinkydeveloper committed May 14, 2024
1 parent 212f115 commit a662c68
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
10 changes: 5 additions & 5 deletions crates/service-protocol/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ mod mocks {
AwakeableEnrichmentResult, CallEnrichmentResult, EnrichedEntryHeader, EnrichedRawEntry,
};
use restate_types::journal::{
AwakeableEntry, CompletableEntry, CompleteAwakeableEntry, EntryEmptyOrResult, EntryResult,
GetStateKeysEntry, GetStateKeysResult, InputEntry, OutputEntry,
AwakeableEntry, CompletableEntry, CompleteAwakeableEntry, EntryResult, GetStateKeysEntry,
GetStateKeysResult, InputEntry, OutputEntry,
};

impl ProtobufRawEntryCodec {
Expand Down Expand Up @@ -223,13 +223,13 @@ mod mocks {
GetStateEntryMessage {
key: entry.key,
result: entry.value.map(|value| match value {
EntryEmptyOrResult::Empty => {
CompletionResult::Empty => {
get_state_entry_message::Result::Empty(protocol::Empty {})
}
EntryEmptyOrResult::Result(v) => {
CompletionResult::Success(v) => {
get_state_entry_message::Result::Value(v)
}
EntryEmptyOrResult::Failure(code, reason) => {
CompletionResult::Failure(code, reason) => {
get_state_entry_message::Result::Failure(Failure {
code: code.into(),
message: reason.to_string(),
Expand Down
12 changes: 6 additions & 6 deletions crates/service-protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ mod pb_into {
Ok(Self::GetState(GetStateEntry {
key: msg.key,
value: msg.result.map(|v| match v {
get_state_entry_message::Result::Empty(_) => EntryEmptyOrResult::Empty,
get_state_entry_message::Result::Value(b) => EntryEmptyOrResult::Result(b),
get_state_entry_message::Result::Empty(_) => CompletionResult::Empty,
get_state_entry_message::Result::Value(b) => CompletionResult::Success(b),
get_state_entry_message::Result::Failure(failure) => {
EntryEmptyOrResult::Failure(failure.code.into(), failure.message.into())
CompletionResult::Failure(failure.code.into(), failure.message.into())
}
}),
}))
Expand Down Expand Up @@ -139,10 +139,10 @@ mod pb_into {
Ok(Self::PeekPromise(PeekPromiseEntry {
key: msg.key.into(),
value: msg.result.map(|v| match v {
peek_promise_entry_message::Result::Empty(_) => EntryEmptyOrResult::Empty,
peek_promise_entry_message::Result::Value(b) => EntryEmptyOrResult::Result(b),
peek_promise_entry_message::Result::Empty(_) => CompletionResult::Empty,
peek_promise_entry_message::Result::Value(b) => CompletionResult::Success(b),
peek_promise_entry_message::Result::Failure(failure) => {
EntryEmptyOrResult::Failure(failure.code.into(), failure.message.into())
CompletionResult::Failure(failure.code.into(), failure.message.into())
}
}),
}))
Expand Down
22 changes: 12 additions & 10 deletions crates/types/src/journal/entries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl Entry {
Entry::Output(OutputEntry { result })
}

pub fn get_state(key: impl Into<Bytes>, value: Option<EntryEmptyOrResult>) -> Self {
pub fn get_state(key: impl Into<Bytes>, value: Option<CompletionResult>) -> Self {
Entry::GetState(GetStateEntry {
key: key.into(),
value,
Expand Down Expand Up @@ -137,6 +137,15 @@ impl From<ResponseResult> for CompletionResult {
}
}

impl From<EntryResult> for CompletionResult {
fn from(value: EntryResult) -> Self {
match value {
EntryResult::Success(s) => CompletionResult::Success(s),
EntryResult::Failure(c, m) => CompletionResult::Failure(c, m),
}
}
}

impl From<&InvocationError> for CompletionResult {
fn from(value: &InvocationError) -> Self {
CompletionResult::Failure(value.code(), value.message().into())
Expand Down Expand Up @@ -216,17 +225,10 @@ pub struct OutputEntry {
pub result: EntryResult,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum EntryEmptyOrResult {
Empty,
Result(Bytes),
Failure(InvocationErrorCode, ByteString),
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct GetStateEntry {
pub key: Bytes,
pub value: Option<EntryEmptyOrResult>,
pub value: Option<CompletionResult>,
}

impl CompletableEntry for GetStateEntry {
Expand Down Expand Up @@ -278,7 +280,7 @@ impl CompletableEntry for GetPromiseEntry {
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PeekPromiseEntry {
pub key: ByteString,
pub value: Option<EntryEmptyOrResult>,
pub value: Option<CompletionResult>,
}

impl CompletableEntry for PeekPromiseEntry {
Expand Down

0 comments on commit a662c68

Please sign in to comment.