Skip to content

Commit ecb5116

Browse files
AhmedSolimanclaude
andcommitted
Introduce restate-sharding crate
Part of the effort to decompose the restate-types monolith into focused, composable utility crates. Add a new `restate-sharding` crate (in `crates/sharding/`) that defines the foundational sharding types: - `KeyRange`: a compact `Copy` newtype over `std::range::RangeInclusive<u64>`. 16 bytes (vs 24 for std::ops::RangeInclusive), wire-format compatible serde and bilrost encoding. Provides iter(), is_overlapping(), and split() helpers. - `PartitionKey`: type alias for u64 - `WithPartitionKey`: trait for types that carry a partition key The crate is re-exported from `restate-types::sharding` for ergonomic access. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4e30658 commit ecb5116

11 files changed

Lines changed: 568 additions & 20 deletions

File tree

Cargo.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ restate-service-protocol = { path = "crates/service-protocol" }
8383
restate-service-protocol-v4 = { path = "crates/service-protocol-v4" }
8484
restate-storage-api = { path = "crates/storage-api" }
8585
restate-storage-query-datafusion = { path = "crates/storage-query-datafusion" }
86+
restate-sharding = { path = "crates/sharding" }
8687
restate-util-string = { path = "util/string" }
8788
restate-test-util = { path = "crates/test-util" }
8889
restate-time-util = { path = "crates/time-util" }

crates/encoding/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ bytestring = { workspace = true }
1818

1919
[dev-dependencies]
2020
rand = { workspace = true }
21+
restate-sharding = { workspace = true, features = ["bilrost"] }
2122
static_assertions = { workspace = true }

crates/sharding/Cargo.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[package]
2+
name = "restate-sharding"
3+
version.workspace = true
4+
authors.workspace = true
5+
edition.workspace = true
6+
rust-version.workspace = true
7+
license.workspace = true
8+
publish = false
9+
10+
[features]
11+
default = []
12+
serde = ["dep:serde"]
13+
bilrost = ["dep:bilrost"]
14+
15+
[dependencies]
16+
restate-workspace-hack = { workspace = true }
17+
18+
bilrost = { workspace = true, optional = true }
19+
serde = { workspace = true, optional = true }
20+
21+
[dev-dependencies]
22+
restate-sharding = { path = ".", default-features = false, features = ["serde", "bilrost"] }
23+
24+
flexbuffers = { workspace = true }
25+
serde = { workspace = true }
26+
serde_json = { workspace = true }

0 commit comments

Comments
 (0)