Skip to content

Commit

Permalink
Move MetadataKind from node.proto to common.proto
Browse files Browse the repository at this point in the history
Move MetadataKind from node.proto to common.proto. With this change, users of the node_ctl_svc.proto only
need to import the common.proto
  • Loading branch information
tillrohrmann committed Jan 7, 2025
1 parent ed1bfbe commit 1132f50
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
3 changes: 1 addition & 2 deletions crates/core/protobuf/node_ctl_svc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ syntax = "proto3";

import "google/protobuf/empty.proto";
import "restate/common.proto";
import "restate/node.proto";

package restate.node_ctl_svc;

Expand Down Expand Up @@ -45,7 +44,7 @@ message GetMetadataRequest {
// If set, we'll first sync with metadata store to esnure we are returning the latest value.
// Otherwise, we'll return the local value on this node.
bool sync = 1;
restate.node.MetadataKind kind = 2;
restate.common.MetadataKind kind = 2;
}

message GetMetadataResponse {
Expand Down
8 changes: 8 additions & 0 deletions crates/types/protobuf/restate/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,11 @@ enum IngressStatus {
IngressStatus_READY = 1;
IngressStatus_STARTING_UP = 2;
}

enum MetadataKind {
MetadataKind_UNKNOWN = 0;
NODES_CONFIGURATION = 1;
SCHEMA = 2;
PARTITION_TABLE = 3;
LOGS = 4;
}
10 changes: 0 additions & 10 deletions crates/types/protobuf/restate/node.proto
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,3 @@ message Message {
BinaryMessage encoded = 5;
}
}

// # Common node types

enum MetadataKind {
MetadataKind_UNKNOWN = 0;
NODES_CONFIGURATION = 1;
SCHEMA = 2;
PARTITION_TABLE = 3;
LOGS = 4;
}
18 changes: 10 additions & 8 deletions crates/types/src/net/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ define_message! {
IntoProto,
FromProto,
)]
#[proto(target = "crate::protobuf::node::MetadataKind")]
#[proto(target = "crate::protobuf::common::MetadataKind")]
pub enum MetadataKind {
NodesConfiguration,
Schema,
Expand All @@ -74,18 +74,20 @@ pub enum MetadataKind {
}

// todo remove once prost_dto supports TryFromProto
impl TryFrom<crate::protobuf::node::MetadataKind> for MetadataKind {
impl TryFrom<crate::protobuf::common::MetadataKind> for MetadataKind {
type Error = anyhow::Error;

fn try_from(value: crate::protobuf::node::MetadataKind) -> Result<Self, Self::Error> {
fn try_from(value: crate::protobuf::common::MetadataKind) -> Result<Self, Self::Error> {
match value {
crate::protobuf::node::MetadataKind::Unknown => bail!("unknown metadata kind"),
crate::protobuf::node::MetadataKind::NodesConfiguration => {
crate::protobuf::common::MetadataKind::Unknown => bail!("unknown metadata kind"),
crate::protobuf::common::MetadataKind::NodesConfiguration => {
Ok(MetadataKind::NodesConfiguration)
}
crate::protobuf::node::MetadataKind::Schema => Ok(MetadataKind::Schema),
crate::protobuf::node::MetadataKind::PartitionTable => Ok(MetadataKind::PartitionTable),
crate::protobuf::node::MetadataKind::Logs => Ok(MetadataKind::Logs),
crate::protobuf::common::MetadataKind::Schema => Ok(MetadataKind::Schema),
crate::protobuf::common::MetadataKind::PartitionTable => {
Ok(MetadataKind::PartitionTable)
}
crate::protobuf::common::MetadataKind::Logs => Ok(MetadataKind::Logs),
}
}
}
Expand Down

0 comments on commit 1132f50

Please sign in to comment.