Skip to content
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
7 changes: 7 additions & 0 deletions libs/runtime/core/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ pub const CELERITY_WS_FORBIDDEN_ERROR_CODE: u16 = 4002;
// client to fall back to constrained capabilities (text-only).
pub const CELERITY_WS_CAPABILITIES_SIGNAL: [u8; 4] = [0x1, 0x5, 0x0, 0x0];

// The prefix of a binary acknowledgement, route key `0x4`, followed by the JSON
// body naming the message being acknowledged.
//
// A reserved message requires no acknowledgement of its own and carries no
// message id, which is what the two trailing zero bytes say.
pub const CELERITY_WS_ACK_SIGNAL: [u8; 4] = [0x1, 0x4, 0x0, 0x0];

// The route key for the connect handler for a WebSocket API.
// A handler registered with this route key will be called when a client
// connects to the WebSocket API server after authentication has been performed
Expand Down
9 changes: 9 additions & 0 deletions libs/runtime/core/src/generated/celerity.runtime.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,15 @@ pub struct WebSocketMessage {
/// the two frame types as distinct.
#[prost(bool, tag = "6")]
pub is_binary: bool,
/// The id this message is known by, which is the one the client gave it when
/// it gave one and a runtime generated one otherwise.
///
/// Distinct from request_id, which identifies the delivery. This identifies
/// the message, so it is what an acknowledgement names and what a lost
/// message notification refers to, and a handler needs it to tie its own
/// instrumentation to what the client sees.
#[prost(string, tag = "7")]
pub message_id: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ConsumerBatch {
Expand Down
1 change: 1 addition & 0 deletions libs/runtime/core/src/ipc_frames.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ fn websocket_message(message: WebSocketEventData) -> proto::WebSocketMessage {
request_id: message.request_id.unwrap_or_default(),
message: message.message.to_vec(),
is_binary: message.is_binary,
message_id: message.message_id.unwrap_or_default(),
}
}

Expand Down
4 changes: 4 additions & 0 deletions libs/runtime/core/src/ipc_websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ impl IpcWebSocketHandler {
&self,
connection_id: String,
request_id: Option<String>,
message_id: Option<String>,
client_ip: String,
message: Bytes,
is_binary: bool,
Expand All @@ -77,6 +78,7 @@ impl IpcWebSocketHandler {
connection_id,
source_ip: client_ip,
request_id,
message_id,
message,
is_binary,
}),
Expand Down Expand Up @@ -187,6 +189,7 @@ impl WebSocketMessageHandler for IpcWebSocketHandler {
.request_ctx
.as_ref()
.map(|ctx| ctx.request_id.clone()),
Some(message.message_id),
message
.request_ctx
.as_ref()
Expand All @@ -212,6 +215,7 @@ impl WebSocketMessageHandler for IpcWebSocketHandler {
.request_ctx
.as_ref()
.map(|ctx| ctx.request_id.clone()),
Some(message.message_id),
message
.request_ctx
.as_ref()
Expand Down
5 changes: 5 additions & 0 deletions libs/runtime/core/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ pub struct WebSocketEventData {
#[serde(rename = "requestId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub request_id: Option<String>,
/// The id the client gave this message, as distinct from `request_id`,
/// which the runtime assigns so that every message can be traced.
#[serde(rename = "messageId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub message_id: Option<String>,
/// The message exactly as it arrived.
pub message: Bytes,
/// Whether this arrived as a binary frame rather than a text one. Bytes
Expand Down
Loading
Loading