Skip to content

Commit 3526e61

Browse files
authored
feat: Prepare raft storage promotion (#659)
Formalize the storage service to become usable for the backend drivers. - add ADR for the storage specification - normalize interface - the storage exposes the command interface - prepare for data encryption: - transfer data as msgpack binary (to be encrypted next) - store data is serialized using msgpack and set/get commands use Serialize/Deserialize for the data for automatic serialization. The data in the store will be encrypted next)
1 parent e62e5bf commit 3526e61

30 files changed

Lines changed: 1106 additions & 623 deletions

Cargo.lock

Lines changed: 16 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
@@ -58,6 +58,7 @@ clap = { version = "4.6" }
5858
color-eyre = { version = "0.6" }
5959
config = { version = "0.15" }
6060
criterion = { version = "0.8" }
61+
dashmap = "6.1"
6162
derive_builder = { version = "0.20" }
6263
dyn-clone = { version = "1.0" }
6364
eyre = { version = "0.6" }

crates/storage/Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,25 @@ workspace = true
1616
[dependencies]
1717
async-trait.workspace = true
1818
byteorder.workspace = true
19+
dashmap.workspace = true
1920
eyre.workspace = true
2021
fjall = { version = "3.1" }
2122
futures.workspace = true
23+
http.workspace = true
2224
openraft = { workspace = true, features = ["serde", "type-alias"] }
2325
openstack-keystone-config = { version = "0.1", path = "../config/" }
2426
prost.workspace = true
2527
rand.workspace = true
28+
rmp.workspace = true
29+
rmp-serde = "1.3"
2630
serde = { workspace = true, features = ["derive"] }
31+
serde_bytes.workspace = true
2732
serde_json.workspace = true
28-
tracing.workspace = true
2933
thiserror.workspace = true
3034
tonic = { workspace = true, features = ["router", "_tls-any"] }
3135
tonic-prost.workspace = true
36+
tracing.workspace = true
37+
tokio.workspace = true
3238

3339
[dev-dependencies]
3440
rcgen = "0.14.7"

crates/storage/build.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
fn main() -> Result<(), Box<dyn std::error::Error>> {
22
let proto_files = [
33
"proto/raft.proto",
4-
"proto/identity_types.proto",
5-
"proto/identity.proto",
4+
"proto/storage_types.proto",
5+
"proto/storage.proto",
66
];
77

88
tonic_prost_build::configure()
@@ -23,11 +23,24 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
2323
"#[derive(Deserialize, Serialize)]",
2424
)
2525
.type_attribute("keystone.raft.Vote", "#[derive(Deserialize, Serialize)]")
26+
.type_attribute("keystone.api.Response", "#[derive(Deserialize, Serialize)]")
2627
.type_attribute(
27-
"keystone.api.SetRequest",
28+
"keystone.api.CommandRequest",
2829
"#[derive(Deserialize, Serialize)]",
2930
)
30-
.type_attribute("keystone.api.Response", "#[derive(Deserialize, Serialize)]")
31+
// .type_attribute(
32+
// "keystone.api.DeleteRequest",
33+
// "#[derive(Deserialize, Serialize)]",
34+
// )
35+
// .type_attribute(
36+
// "keystone.api.StoreRequest",
37+
// "#[derive(Deserialize, Serialize)]",
38+
// )
39+
// .type_attribute(
40+
// "keystone.api.StoreRequest.request",
41+
// "#[derive(serde::Deserialize, serde::Serialize)]",
42+
// )
43+
//.type_attribute("keystone.api.Response", "#[derive(Deserialize, Serialize)]")
3144
.compile_protos(&proto_files, &["proto"])?;
3245
Ok(())
3346
}

crates/storage/proto/identity.proto

Lines changed: 0 additions & 18 deletions
This file was deleted.

crates/storage/proto/identity_types.proto

Lines changed: 0 additions & 23 deletions
This file was deleted.

crates/storage/proto/raft.proto

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ syntax = "proto3";
33
package keystone.raft;
44

55
import "google/protobuf/empty.proto";
6-
import "identity_types.proto";
6+
import "storage_types.proto";
77

88

99
// Node represents a single node in the Raft cluster.
@@ -30,11 +30,11 @@ message Entry {
3030
uint64 term = 1;
3131
uint64 index = 2;
3232

33-
// Optional Application data.
34-
keystone.api.SetRequest app_data = 12;
35-
3633
// Optional Membership config.
37-
Membership membership = 13;
34+
Membership membership = 3;
35+
36+
// Optional Store request.
37+
optional bytes app_data = 4;
3838
}
3939

4040
// NodeIds is a set of NodeIds.
@@ -190,11 +190,11 @@ message AdminResponse {
190190
// The log id of the committed log entry.
191191
keystone.raft.LogId log_id = 1;
192192

193-
// If the committed log entry is a normal one.
194-
keystone.api.Response data = 2;
195-
196193
// If the committed log entry is a change-membership entry.
197-
keystone.raft.Membership membership = 3;
194+
keystone.raft.Membership membership = 2;
195+
196+
// If the committed log entry is a normal one.
197+
keystone.api.Response data = 3;
198198
}
199199

200200
message MetricsResponse {
@@ -224,3 +224,4 @@ service ClusterAdminService {
224224
// Metrics retrieves cluster metrics and status information.
225225
rpc Metrics(google.protobuf.Empty) returns (MetricsResponse) {}
226226
}
227+

crates/storage/proto/storage.proto

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
syntax = "proto3";
2+
3+
package keystone.api;
4+
5+
import "google/protobuf/empty.proto";
6+
import "google/protobuf/wrappers.proto";
7+
import "storage_types.proto";
8+
9+
// StorageService provides the key-value store API operations.
10+
service StorageService {
11+
// Write the command
12+
rpc Command(keystone.api.CommandRequest) returns (keystone.api.Response) {}
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
syntax = "proto3";
2+
3+
package keystone.api;
4+
5+
message CommandRequest {
6+
// Store request.
7+
bytes payload = 1;
8+
}
9+
10+
// GetResponse contains the value associated with the requested key.
11+
message Response {
12+
// Retrieved value.
13+
optional bytes value = 1;
14+
}

0 commit comments

Comments
 (0)