Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate key in StartMessage #1247

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/invoker-impl/src/invocation_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,10 @@ where
ProtocolMessage::new_start_message(
Bytes::copy_from_slice(&self.full_invocation_id.to_invocation_id_bytes()),
self.full_invocation_id.to_string(),
Some(self.full_invocation_id.service_id.key.clone()),
journal_size,
is_partial,
iter::empty(),
state_entries,
),
)
Expand Down
11 changes: 9 additions & 2 deletions crates/service-protocol/src/message/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,15 @@ mod tests {
let encoder = Encoder::new(protocol_version);
let mut decoder = Decoder::default();

let expected_msg_0 =
ProtocolMessage::new_start_message("key".into(), "key".into(), 1, true, vec![]);
let expected_msg_0 = ProtocolMessage::new_start_message(
"key".into(),
"key".into(),
Some("key".into()),
1,
true,
vec![],
vec![],
);

let expected_msg_1: ProtocolMessage =
ProtobufRawEntryCodec::serialize_as_unary_input_entry(Bytes::from_static(
Expand Down
10 changes: 9 additions & 1 deletion crates/service-protocol/src/message/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ impl ProtocolMessage {
pub fn new_start_message(
id: Bytes,
debug_id: String,
key: Option<Bytes>,
known_entries: u32,
partial_state: bool,
headers: impl IntoIterator<Item = (String, String)>,
state_map_entries: impl IntoIterator<Item = (Bytes, Bytes)>,
) -> Self {
Self::Start(pb::protocol::StartMessage {
Expand All @@ -57,7 +59,13 @@ impl ProtocolMessage {
.into_iter()
.map(|(key, value)| pb::protocol::start_message::StateEntry { key, value })
.collect(),
..pb::protocol::StartMessage::default()
key: key
.and_then(|b| String::from_utf8(b.to_vec()).ok())
.unwrap_or_default(),
headers: headers
.into_iter()
.map(|(key, value)| pb::protocol::Header { key, value })
.collect(),
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,9 +788,11 @@ impl<'a, State: StateReader + Send + Sync> RemoteContextBuiltInService
ProtocolMessage::new_start_message(
Bytes::copy_from_slice(&virtual_invocation_id.to_bytes()),
virtual_invocation_id.to_string(),
None,
length,
true, // TODO add eager state
iter::empty(),
iter::empty(),
),
)
.expect("Encoding messages to a BytesMut should be infallible, unless OOM is reached.");
Expand Down
Loading