Skip to content
This repository has been archived by the owner on Jul 23, 2019. It is now read-only.

Serialize operations using FlatBuffers #160

Merged
merged 22 commits into from
Nov 2, 2018
Merged
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
25 changes: 17 additions & 8 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions memo_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2018"
[dependencies]
difference = "2.0"
lazy_static = "1.0"
flatbuffers = "0.5"
futures = "0.1"
serde = "1.0"
serde_derive = "1.0"
Expand Down
69 changes: 69 additions & 0 deletions memo_core/memo.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
syntax = "proto3";

message EpochOperation {
oneof variant {
InsertMetadata insert_metadata = 1;
UpdateParent update_parent = 2;
EditText edit_text = 3;
}

message InsertMetadata {
FileId file_id = 1;
FileType file_type = 2;
FileId parent_id = 3;
string name_in_parent = 4;
Timestamp local_timestamp = 5;
Timestamp lamport_timestamp = 6;
}

message UpdateParent {
FileId child_id = 1;
FileId new_parent_id = 2;
string new_name_in_parent = 3;
Timestamp local_timestamp = 4;
Timestamp lamport_timestamp = 5;
}

message EditText {
FileId file_id = 1;
repeated BufferOperation edits = 2;
Timestamp local_timestamp = 3;
Timestamp lamport_timestamp = 4;
}

enum FileType {
Directory = 0;
Text = 1;
}
}

message BufferOperation {
Timestamp start_id = 1;
uint64 start_offset = 2;
Timestamp end_id = 3;
uint64 end_offset = 4;
GlobalTimestamp version_in_range = 5;
string new_text = 6;
Timestamp local_timestamp = 7;
Timestamp lamport_timestamp = 8;
}

message FileId {
oneof variant {
uint64 Base = 1;
Timestamp New = 2;
}
}

message Timestamp {
ReplicaId replica_id = 1;
uint64 value = 2;
}

message GlobalTimestamp {
repeated Timestamp timestamps = 1;
}

message ReplicaId {
bytes uuid = 1;
}
6 changes: 6 additions & 0 deletions memo_core/script/compile_flatbuffers
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

flatc --rust -o src/serialization src/serialization/schema.fbs

# Workaround for incorrect code generation by flatc
echo "use flatbuffers::EndianScalar;" >> src/serialization/schema_generated.rs
Loading