-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
731aed2
commit 1ca8e9f
Showing
29 changed files
with
581 additions
and
117 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) 2024 - Restate Software, Inc., Restate GmbH. | ||
// All rights reserved. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the LICENSE file. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0. | ||
|
||
use async_trait::async_trait; | ||
use restate_node_protocol::NetworkMessage; | ||
use restate_types::nodes_config::NodesConfigError; | ||
use restate_types::NodeId; | ||
|
||
use crate::ShutdownError; | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum NetworkSendError { | ||
#[error("Unknown node: {0}")] | ||
UnknownNode(#[from] NodesConfigError), | ||
#[error("Operation aborted, node is shutting down")] | ||
Shutdown(#[from] ShutdownError), | ||
#[error("OldPeerGeneration: {0}")] | ||
OldPeerGeneration(String), | ||
#[error("Cannot send messages to this node: {0}")] | ||
Unavailable(String), | ||
} | ||
|
||
/// Access to node-to-node networking infrastructure | ||
#[async_trait] | ||
pub trait NetworkSender: Send + Sync { | ||
async fn send(&self, to: NodeId, message: &NetworkMessage) -> Result<(), NetworkSendError>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[package] | ||
name = "restate-node-protocol" | ||
version.workspace = true | ||
authors.workspace = true | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
license.workspace = true | ||
publish = false | ||
|
||
[features] | ||
default = [] | ||
|
||
[dependencies] | ||
restate-types = { workspace = true, features = ["serde"] } | ||
|
||
anyhow = { workspace = true, optional = true } | ||
bytes = { workspace = true, optional = true } | ||
enum-map = { workspace = true } | ||
prost = { workspace = true } | ||
prost-types = { workspace = true } | ||
serde = { workspace = true} | ||
strum = { workspace = true } | ||
strum_macros = { workspace = true } | ||
thiserror = { workspace = true, optional = true } | ||
|
||
[build-dependencies] | ||
prost-build = { workspace = true } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) 2024 - Restate Software, Inc., Restate GmbH. | ||
// All rights reserved. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the LICENSE file. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0. | ||
|
||
use std::env; | ||
use std::path::PathBuf; | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); | ||
|
||
prost_build::Config::new() | ||
.bytes(["."]) | ||
.file_descriptor_set_path(out_dir.join("common_descriptor.bin")) | ||
// allow older protobuf compiler to be used | ||
.protoc_arg("--experimental_allow_proto3_optional") | ||
.compile_protos(&["./proto/common.proto"], &["proto"])?; | ||
|
||
prost_build::Config::new() | ||
.enum_attribute( | ||
"MessageKind", | ||
"#[derive(::enum_map::Enum, ::strum_macros::EnumIs)]", | ||
) | ||
.enum_attribute("Message.body", "#[derive(::strum_macros::EnumIs)]") | ||
.bytes(["."]) | ||
.file_descriptor_set_path(out_dir.join("node_descriptor.bin")) | ||
// allow older protobuf compiler to be used | ||
.protoc_arg("--experimental_allow_proto3_optional") | ||
.compile_protos(&["./proto/node.proto"], &["proto"])?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright (c) 2024 - Restate Software, Inc., Restate GmbH | ||
// | ||
// This file is part of the Restate service protocol, which is | ||
// released under the MIT license. | ||
// | ||
// You can find a copy of the license in file LICENSE in the root | ||
// directory of this repository or package, or at | ||
// https://github.com/restatedev/proto/blob/main/LICENSE | ||
|
||
syntax = "proto3"; | ||
|
||
import "common.proto"; | ||
|
||
package dev.restate.node; | ||
|
||
// | ||
// # Wire Protocol Of Streaming Connections | ||
// ------------------------------------- | ||
// | ||
message Header { dev.restate.common.Version my_nodes_config_version = 1; } | ||
|
||
// First message sent to an ingress after starting the connection. The message | ||
// must be sent before any other message. | ||
message Hello { | ||
dev.restate.common.ProtocolVersion min_protocol_version = 1; | ||
dev.restate.common.ProtocolVersion max_protocol_version = 2; | ||
// generational node id of sender (who am I) | ||
dev.restate.common.NodeId my_node_id = 3; | ||
string cluster_name = 4; | ||
} | ||
|
||
message Welcome { | ||
dev.restate.common.ProtocolVersion protocol_version = 2; | ||
// generational node id of sender | ||
dev.restate.common.NodeId my_node_id = 3; | ||
} | ||
|
||
enum MessageKind { | ||
MessageKind_UNKNOWN = 0; | ||
GET_METADATA_REQUEST = 1; | ||
METADATA_UPDATE = 2; | ||
} | ||
|
||
// Bidirectional Communication | ||
message Message { | ||
enum Signal { | ||
Signal_UNKNOWN = 0; | ||
SHUTDOWN = 1; | ||
// Connection will be dropped | ||
DRAIN_CONNECTION = 2; | ||
CODEC_ERROR = 3; | ||
} | ||
message ConnectionControl { | ||
Signal signal = 1; | ||
string message = 2; | ||
} | ||
|
||
message BinaryMessage { | ||
MessageKind kind = 1; | ||
bytes payload = 2; | ||
} | ||
|
||
Header header = 1; | ||
oneof body { | ||
ConnectionControl connection_control = 2; | ||
// Sent as first message | ||
Hello hello = 3; | ||
// Sent as first response | ||
Welcome welcome = 4; | ||
BinaryMessage bincoded = 5; | ||
} | ||
} |
Oops, something went wrong.