Skip to content

Commit

Permalink
[Mechanical] Upgrade prost-dto to 0.0.3
Browse files Browse the repository at this point in the history
prost-dto 0.0.3 renames IntoProto/FromProto to `IntoProst/FromProst` and all macro attributes accordingly. It also removes the auto skipping of fields, only fields marked with `#[prost(skip)]` are now skipped.
  • Loading branch information
AhmedSoliman committed Jan 8, 2025
1 parent 22fcef1 commit 85c8fb3
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 59 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ pin-project-lite = { version = "0.2" }
prost = { version = "0.13.1" }
prost-build = { version = "0.13.1" }
priority-queue = "2.0.3"
prost-dto = { version = "0.0.2" }
prost-dto = { version = "0.0.3" }
prost-types = { version = "0.13.1" }
rand = "0.8.5"
rayon = { version = "1.10" }
Expand Down
12 changes: 6 additions & 6 deletions crates/node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mod roles;

use anyhow::Context;
use bytestring::ByteString;
use prost_dto::IntoProto;
use prost_dto::IntoProst;
use std::num::NonZeroU16;
use tracing::{debug, error, info, trace, warn};

Expand Down Expand Up @@ -540,14 +540,14 @@ impl Node {
}
}

#[derive(Clone, Debug, IntoProto)]
#[proto(target = "restate_types::protobuf::cluster::ClusterConfiguration")]
#[derive(Clone, Debug, IntoProst)]
#[prost(target = "restate_types::protobuf::cluster::ClusterConfiguration")]
pub struct ClusterConfiguration {
#[into_proto(map = "num_partitions_to_u32")]
#[into_prost(map = "num_partitions_to_u32")]
pub num_partitions: NonZeroU16,
#[proto(required)]
#[prost(required)]
pub replication_strategy: ReplicationStrategy,
#[proto(required)]
#[prost(required)]
pub default_provider: ProviderConfiguration,
}

Expand Down
52 changes: 26 additions & 26 deletions crates/types/src/cluster/cluster_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use std::collections::BTreeMap;
use std::time::Instant;

use prost_dto::IntoProto;
use prost_dto::IntoProst;
use serde::{Deserialize, Serialize};

use crate::identifiers::{LeaderEpoch, PartitionId};
Expand All @@ -21,16 +21,16 @@ use crate::{GenerationalNodeId, PlainNodeId, Version};

/// A container for health information about every node and partition in the
/// cluster.
#[derive(Debug, Clone, IntoProto)]
#[proto(target = "crate::protobuf::cluster::ClusterState")]
#[derive(Debug, Clone, IntoProst)]
#[prost(target = "crate::protobuf::cluster::ClusterState")]
pub struct ClusterState {
#[into_proto(map = "instant_to_proto")]
#[into_prost(map = "instant_to_proto")]
pub last_refreshed: Option<Instant>,
#[proto(required)]
#[prost(required)]
pub nodes_config_version: Version,
#[proto(required)]
#[prost(required)]
pub partition_table_version: Version,
#[proto(required)]
#[prost(required)]
pub logs_metadata_version: Version,
pub nodes: BTreeMap<PlainNodeId, NodeState>,
}
Expand Down Expand Up @@ -74,62 +74,62 @@ fn instant_to_proto(t: Instant) -> prost_types::Duration {
t.elapsed().try_into().unwrap()
}

#[derive(Debug, Clone, IntoProto)]
#[proto(target = "crate::protobuf::cluster::NodeState", oneof = "state")]
#[derive(Debug, Clone, IntoProst)]
#[prost(target = "crate::protobuf::cluster::NodeState", oneof = "state")]
pub enum NodeState {
Alive(AliveNode),
Dead(DeadNode),
Suspect(SuspectNode),
}

#[derive(Debug, Clone, IntoProto)]
#[proto(target = "crate::protobuf::cluster::AliveNode")]
#[derive(Debug, Clone, IntoProst)]
#[prost(target = "crate::protobuf::cluster::AliveNode")]
pub struct AliveNode {
#[proto(required)]
#[prost(required)]
pub last_heartbeat_at: MillisSinceEpoch,
#[proto(required)]
#[prost(required)]
pub generational_node_id: GenerationalNodeId,
pub partitions: BTreeMap<PartitionId, PartitionProcessorStatus>,
}

#[derive(Debug, Clone, IntoProto)]
#[proto(target = "crate::protobuf::cluster::DeadNode")]
#[derive(Debug, Clone, IntoProst)]
#[prost(target = "crate::protobuf::cluster::DeadNode")]
pub struct DeadNode {
pub last_seen_alive: Option<MillisSinceEpoch>,
}

#[derive(Debug, Clone, IntoProto)]
#[proto(target = "crate::protobuf::cluster::SuspectNode")]
#[derive(Debug, Clone, IntoProst)]
#[prost(target = "crate::protobuf::cluster::SuspectNode")]
/// As the name implies, SuspectNode is both dead and alive
/// until we receive a heartbeat
pub struct SuspectNode {
#[proto(required)]
#[prost(required)]
pub generational_node_id: GenerationalNodeId,
#[proto(required)]
#[prost(required)]
pub last_attempt: MillisSinceEpoch,
}

#[derive(
Debug, Clone, Copy, Serialize, Deserialize, Eq, PartialEq, IntoProto, derive_more::Display,
Debug, Clone, Copy, Serialize, Deserialize, Eq, PartialEq, IntoProst, derive_more::Display,
)]
#[proto(target = "crate::protobuf::cluster::RunMode")]
#[prost(target = "crate::protobuf::cluster::RunMode")]
pub enum RunMode {
Leader,
Follower,
}

#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize, IntoProto)]
#[proto(target = "crate::protobuf::cluster::ReplayStatus")]
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize, IntoProst)]
#[prost(target = "crate::protobuf::cluster::ReplayStatus")]
pub enum ReplayStatus {
Starting,
Active,
CatchingUp,
}

#[derive(Debug, Clone, Serialize, Deserialize, IntoProto)]
#[proto(target = "crate::protobuf::cluster::PartitionProcessorStatus")]
#[derive(Debug, Clone, Serialize, Deserialize, IntoProst)]
#[prost(target = "crate::protobuf::cluster::PartitionProcessorStatus")]
pub struct PartitionProcessorStatus {
#[proto(required)]
#[prost(required)]
pub updated_at: MillisSinceEpoch,
pub planned_mode: RunMode,
pub effective_mode: RunMode,
Expand Down
30 changes: 15 additions & 15 deletions crates/types/src/net/log_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::ops::{Deref, DerefMut};
use std::sync::Arc;

use bitflags::bitflags;
use prost_dto::{FromProto, IntoProto};
use prost_dto::{FromProst, IntoProst};
use serde::{Deserialize, Serialize};

use super::codec::{WireDecode, WireEncode};
Expand Down Expand Up @@ -69,8 +69,8 @@ macro_rules! define_logserver_rpc {
};
}

#[derive(Debug, Clone, Copy, Eq, PartialEq, Serialize, Deserialize, IntoProto, FromProto)]
#[proto(target = "crate::protobuf::log_server_common::Status")]
#[derive(Debug, Clone, Copy, Eq, PartialEq, Serialize, Deserialize, IntoProst, FromProst)]
#[prost(target = "crate::protobuf::log_server_common::Status")]
#[repr(u8)]
pub enum Status {
/// Operation was successful
Expand Down Expand Up @@ -180,8 +180,8 @@ impl LogServerRequestHeader {
}
}

#[derive(Debug, Clone, Serialize, Deserialize, IntoProto, FromProto)]
#[proto(target = "crate::protobuf::log_server_common::ResponseHeader")]
#[derive(Debug, Clone, Serialize, Deserialize, IntoProst, FromProst)]
#[prost(target = "crate::protobuf::log_server_common::ResponseHeader")]
pub struct LogServerResponseHeader {
/// The position after the last locally committed record on this node
pub local_tail: LogletOffset,
Expand Down Expand Up @@ -385,10 +385,10 @@ pub struct GetLogletInfo {
pub header: LogServerRequestHeader,
}

#[derive(Debug, Clone, Serialize, Deserialize, IntoProto)]
#[proto(target = "crate::protobuf::log_server_common::LogletInfo")]
#[derive(Debug, Clone, Serialize, Deserialize, IntoProst)]
#[prost(target = "crate::protobuf::log_server_common::LogletInfo")]
pub struct LogletInfo {
#[proto(required)]
#[prost(required)]
pub header: LogServerResponseHeader,
pub trim_point: LogletOffset,
}
Expand Down Expand Up @@ -656,9 +656,9 @@ pub struct GetDigest {
}

#[derive(
Debug, Clone, PartialEq, Eq, derive_more::Display, Serialize, Deserialize, IntoProto, FromProto,
Debug, Clone, PartialEq, Eq, derive_more::Display, Serialize, Deserialize, IntoProst, FromProst,
)]
#[proto(target = "crate::protobuf::log_server_common::DigestEntry")]
#[prost(target = "crate::protobuf::log_server_common::DigestEntry")]
#[display("[{from_offset}..{to_offset}] -> {status} ({})", self.len())]
pub struct DigestEntry {
// inclusive
Expand All @@ -668,10 +668,10 @@ pub struct DigestEntry {
}

#[derive(
Debug, Clone, Eq, PartialEq, derive_more::Display, Serialize, Deserialize, IntoProto, FromProto,
Debug, Clone, Eq, PartialEq, derive_more::Display, Serialize, Deserialize, IntoProst, FromProst,
)]
#[repr(u8)]
#[proto(target = "crate::protobuf::log_server_common::RecordStatus")]
#[prost(target = "crate::protobuf::log_server_common::RecordStatus")]
pub enum RecordStatus {
#[display("T")]
Trimmed,
Expand All @@ -697,10 +697,10 @@ impl DigestEntry {
}

/// Response to a `GetDigest` request
#[derive(Debug, Clone, Serialize, Deserialize, IntoProto, FromProto)]
#[proto(target = "crate::protobuf::log_server_common::Digest")]
#[derive(Debug, Clone, Serialize, Deserialize, IntoProst, FromProst)]
#[prost(target = "crate::protobuf::log_server_common::Digest")]
pub struct Digest {
#[proto(required)]
#[prost(required)]
pub header: LogServerResponseHeader,
// If the node's local trim-point (or archival-point) overlaps with the digest range, an entry will be
// added to include where the trim-gap ends. Otherwise, offsets for non-existing records
Expand Down
10 changes: 5 additions & 5 deletions crates/types/src/net/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use anyhow::bail;
use enum_map::Enum;
use prost_dto::{FromProto, IntoProto};
use prost_dto::{FromProst, IntoProst};
use serde::{Deserialize, Serialize};
use std::sync::Arc;
use strum::EnumIter;
Expand Down Expand Up @@ -62,18 +62,18 @@ define_message! {
Deserialize,
derive_more::Display,
strum::EnumCount,
IntoProto,
FromProto,
IntoProst,
FromProst,
)]
#[proto(target = "crate::protobuf::common::MetadataKind")]
#[prost(target = "crate::protobuf::common::MetadataKind")]
pub enum MetadataKind {
NodesConfiguration,
Schema,
PartitionTable,
Logs,
}

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

Expand Down

0 comments on commit 85c8fb3

Please sign in to comment.