Skip to content
Draft
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 AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ If these rules conflict with normal behavior, always follow the rules above.
1. New or deprecated config options must have `/// Since vX.Y.Z` in their doc comment.
1. Use `ByteCount::from(value)` (from `restate_memory`) when displaying byte sizes in errors/logs.
1. Use `KeyRange` (from `restate_sharding`, re-exported via `restate_types::sharding::KeyRange`) instead of `std::ops::RangeInclusive<PartitionKey>` for partition key ranges. `KeyRange` is `Copy`, 16 bytes (vs 24), and has wire-compatible serde/bilrost encoding.
1. Use types from `restate_platform` instead of their std equivalents: `restate_platform::hash::{HashMap, HashSet}` instead of `std::collections::{HashMap, HashSet}`, and `restate_platform::sync::{Mutex, RwLock}` instead of `std::sync::{Mutex, RwLock}`. The `restate_platform::prelude::*` re-exports the most common types and traits. See `clippy.toml` for the enforced `disallowed_types` list.


# Validation Before Committing Changes
Expand Down
29 changes: 23 additions & 6 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ restate-metadata-store = { path = "crates/metadata-store" }
restate-node = { path = "crates/node" }
restate-object-store-util = { path = "crates/object-store-util" }
restate-partition-store = { path = "crates/partition-store" }
restate-platform = { path = "crates/platform" }
restate-queue = { path = "crates/queue" }
restate-rocksdb = { path = "crates/rocksdb" }
restate-serde-util = { path = "crates/serde-util" }
Expand Down Expand Up @@ -332,6 +333,10 @@ opt-level = 2
[profile.dist]
inherits = "release"

[workspace.lints.clippy]
# Prefer restate-platform's re-exports over direct std usage. See clippy.toml for the list.
disallowed_types = "warn"

[workspace.lints.rust]
# Temporarily allow unused assignments until https://github.com/rust-lang/rust/issues/147648 has been fixed.
# The problem is that error fields used by thiserror::error attribute generate false positives for unused_assignments.
Expand Down
9 changes: 9 additions & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,12 @@
ignore-interior-mutability = ["bytes::Bytes", "bytestring::ByteString", "http::header::HeaderName", "http::header::HeaderValue"]
# Sometimes we want to keep the mod.rs file clean
allow-private-module-inception = true

# Prefer restate-platform's re-exports over direct std usage.
# Activated by the clippy::disallowed_types lint in [workspace.lints.clippy].
disallowed-types = [
{ path = "std::sync::Mutex", reason = "use `restate_platform::sync::Mutex` instead" },
{ path = "std::sync::RwLock", reason = "use `restate_platform::sync::RwLock` instead" },
{ path = "std::collections::HashMap", reason = "use `restate_platform::hash::HashMap` instead" },
{ path = "std::collections::HashSet", reason = "use `restate_platform::hash::HashSet` instead" },
]
3 changes: 2 additions & 1 deletion crates/clock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ test-util = []

[dependencies]
restate-workspace-hack = { workspace = true }
restate-encoding = { workspace = true }

restate-platform = { workspace = true }

bilrost = { workspace = true }
jiff = { workspace = true, optional = true }
Expand Down
4 changes: 3 additions & 1 deletion crates/clock/src/rough_ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use std::num::NonZeroU32;
use std::ops::{Add, Sub};
use std::time::Duration;

use restate_platform::network::NetSerde;

use crate::WallClock;
use crate::time::MillisSinceEpoch;
use crate::unique_timestamp::UniqueTimestamp;
Expand Down Expand Up @@ -45,7 +47,7 @@ impl fmt::Debug for RoughTimestamp {
}
}

impl restate_encoding::NetSerde for RoughTimestamp {}
impl NetSerde for RoughTimestamp {}

const _: () = {
assert!(
Expand Down
6 changes: 4 additions & 2 deletions crates/clock/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ use std::time::{Duration, SystemTime};
// Note: BilrostNewType and NetSerde derives are not used since both MillisSinceEpoch
// and NanosSinceEpoch have custom implementations for niche optimization.

use restate_platform::network::NetSerde;

use crate::WallClock;

/// Milliseconds since the unix epoch.
Expand Down Expand Up @@ -46,7 +48,7 @@ impl fmt::Debug for MillisSinceEpoch {
}
}

impl restate_encoding::NetSerde for MillisSinceEpoch {}
impl NetSerde for MillisSinceEpoch {}

// Static assertions to ensure that MillisSinceEpoch is the same size as u64
// and that niche optimization works.
Expand Down Expand Up @@ -376,7 +378,7 @@ impl fmt::Debug for NanosSinceEpoch {
}
}

impl restate_encoding::NetSerde for NanosSinceEpoch {}
impl NetSerde for NanosSinceEpoch {}

// Static assertions to ensure that NanosSinceEpoch is the same size as u64
// and that niche optimization works.
Expand Down
1 change: 1 addition & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ restate-core-derive = { workspace = true, optional = true }
restate-futures-util = { workspace = true }
restate-memory = { workspace = true }
restate-metadata-store = { workspace = true }
restate-platform = { workspace = true }
restate-time-util = { workspace = true }
restate-types = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/network/incoming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::marker::PhantomData;
use bytes::Bytes;
use tokio::sync::{oneshot, watch};

use restate_memory::EstimatedMemorySize;
use restate_platform::memory::EstimatedMemorySize;

pub use restate_memory::MemoryLease;
use restate_types::GenerationalNodeId;
Expand Down
3 changes: 2 additions & 1 deletion crates/core/src/network/message_router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ use tokio::sync::{mpsc, oneshot, watch};
use tokio_stream::StreamExt;
use tracing::{debug, instrument, trace, warn};

use restate_memory::{EstimatedMemorySize, MemoryLease, MemoryPool};
use restate_memory::{MemoryLease, MemoryPool};
use restate_platform::memory::EstimatedMemorySize;
use restate_types::SharedString;
use restate_types::net::{Service, ServiceTag};

Expand Down
5 changes: 1 addition & 4 deletions crates/encoding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ publish = false
restate-workspace-hack = { workspace = true }

restate-encoding-derive = { version = "0.1.0", path = "derive" }
restate-sharding = { workspace = true }
restate-platform = { workspace = true }

bilrost = { workspace = true }
bytes = { workspace = true }
bytestring = { workspace = true }

[dev-dependencies]
rand = { workspace = true }
restate-sharding = { workspace = true, features = ["bilrost"] }
static_assertions = { workspace = true }
4 changes: 2 additions & 2 deletions crates/encoding/derive/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ pub fn net_serde_inner(input: DeriveInput) -> Result<TokenStream, syn::Error> {

let where_clauses = field_types.iter().map(|ty| {
quote! {
#ty: NetSerde
#ty: ::restate_platform::network::NetSerde
}
});

let expanded = quote! {
impl ::restate_encoding::NetSerde for #name where #(#where_clauses),* {}
impl ::restate_platform::network::NetSerde for #name where #(#where_clauses),* {}
};

Ok(TokenStream::from(expanded))
Expand Down
3 changes: 2 additions & 1 deletion crates/encoding/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ use bilrost::{
encoding::{EmptyState, ForOverwrite, Proxiable},
};
use restate_encoding_derive::BilrostNewType;
use restate_platform::network::NetSerde;

use crate::{NetSerde, bilrost_encodings::RestateEncoding};
use crate::bilrost_encodings::RestateEncoding;

struct U128Tag;

Expand Down
Loading
Loading