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

Unify RpcStyle message routing #1511

Merged
merged 1 commit into from
May 16, 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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 5 additions & 12 deletions crates/ingress-dispatcher/src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@

use crate::error::IngressDispatchError;
use crate::{
IngressCorrelationId, IngressDispatcherRequest, IngressDispatcherRequestInner,
IngressDispatcherResponse, IngressRequestMode, IngressResponseSender,
IngressDispatcherRequest, IngressDispatcherRequestInner, IngressDispatcherResponse,
IngressRequestMode, IngressResponseSender,
};
use dashmap::DashMap;
use restate_bifrost::Bifrost;
use restate_core::metadata;
use restate_core::network::MessageHandler;
use restate_node_protocol::codec::Targeted;
use restate_node_protocol::ingress::IngressMessage;
use restate_node_protocol::ingress::{IngressCorrelationId, IngressMessage};
use restate_node_protocol::RpcMessage;
use restate_storage_api::deduplication_table::DedupInformation;
use restate_types::identifiers::{PartitionKey, WithPartitionKey};
use restate_types::message::MessageIndex;
Expand Down Expand Up @@ -132,15 +133,7 @@ impl MessageHandler for IngressDispatcher {
trace!("Processing message '{}' from '{}'", msg.kind(), peer);
match msg {
IngressMessage::InvocationResponse(invocation_response) => {
let correlation_id = invocation_response
.idempotency_id
.as_ref()
.map(|idempotency_id| {
IngressCorrelationId::IdempotencyId(idempotency_id.clone())
})
.unwrap_or_else(|| {
IngressCorrelationId::InvocationId(invocation_response.invocation_id)
});
let correlation_id = invocation_response.correlation_id();
if let Some((_, sender)) = self.state.waiting_responses.remove(&correlation_id) {
let dispatcher_response = IngressDispatcherResponse {
// TODO we need to add back the expiration time for idempotent results
Expand Down
9 changes: 1 addition & 8 deletions crates/ingress-dispatcher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use bytes::Bytes;
use bytestring::ByteString;
use restate_core::metadata;
pub use restate_node_protocol::ingress::IngressCorrelationId;
use restate_schema_api::subscription::{EventReceiverServiceType, Sink, Subscription};
use restate_types::identifiers::{
partitioner, IdempotencyId, InvocationId, PartitionKey, WithPartitionKey,
Expand All @@ -32,14 +33,6 @@ pub use dispatcher::{DispatchIngressRequest, IngressDispatcher};
pub type IngressResponseSender = oneshot::Sender<IngressDispatcherResponse>;
pub type IngressResponseReceiver = oneshot::Receiver<IngressDispatcherResponse>;

// TODO we could eventually remove this type and replace it with something simpler once
// https://github.com/restatedev/restate/issues/1329 is in place
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum IngressCorrelationId {
InvocationId(InvocationId),
IdempotencyId(IdempotencyId),
}

#[derive(Debug)]
enum IngressDispatcherRequestInner {
Invoke(ServiceInvocation),
Expand Down
1 change: 1 addition & 0 deletions crates/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ anyhow = { workspace = true }
async-trait = { workspace = true }
bincode = { workspace = true }
bytes = { workspace = true }
dashmap = { workspace = true }
drain = { workspace = true }
enum-map = { workspace = true }
enumset = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions crates/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub mod error;
mod handshake;
pub(crate) mod metric_definitions;
mod networking;
pub mod rpc_router;

pub use connection::ConnectionSender;
pub use connection_manager::ConnectionManager;
Expand Down
Loading
Loading