-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace the UDP replication protocol with gRPC for the distributed store #337
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use std::error::Error; | ||
use std::path::Path; | ||
|
||
fn main() -> Result<(), Box<dyn Error>> { | ||
generate_protobuf() | ||
} | ||
|
||
fn generate_protobuf() -> Result<(), Box<dyn Error>> { | ||
if cfg!(feature = "distributed_storage") { | ||
let proto_path: &Path = "proto/distributed.proto".as_ref(); | ||
|
||
let proto_dir = proto_path | ||
.parent() | ||
.expect("proto file should reside in a directory"); | ||
|
||
tonic_build::configure() | ||
.protoc_arg("--experimental_allow_proto3_optional") | ||
.compile(&[proto_path], &[proto_dir])?; | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
syntax = "proto3"; | ||
|
||
package limitador.service.distributed.v1; | ||
|
||
// A packet defines all the types of messages that can be sent between replication peers. | ||
message Packet { | ||
oneof message { | ||
// the Hello message is used to introduce a peer to another peer. It is the first message sent by a peer. | ||
Hello hello = 1; | ||
// the MembershipUpdate message is used to gossip about the other peers in the cluster: | ||
// 1) sent after the first Hello message | ||
// 2) sent when the membership state changes | ||
MembershipUpdate membership_update = 2; | ||
// the Ping message is used to request a pong from the other peer. | ||
Ping ping = 3; | ||
// the Pong message is used to respond to a ping. | ||
Pong pong = 4; | ||
// the CounterUpdate message is used to send counter updates. | ||
CounterUpdate counter_update = 5; | ||
} | ||
} | ||
|
||
// this is the first packet sent by a peer to another peer. | ||
message Hello { | ||
// the peer id of the sending peer | ||
string sender_peer_id = 1; | ||
// urls that the sending peer thinks it can be reached at. | ||
repeated string sender_urls = 2; | ||
// url the session initiator used to connect to the receiver peer. | ||
optional string receiver_url = 3; | ||
} | ||
|
||
// A request to a peer to respond with a Pong message. | ||
message Ping {} | ||
|
||
// Pong is the response to a Ping and Hello message. | ||
message Pong { | ||
// the current time at of the peer in milliseconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. | ||
uint64 current_time = 3; | ||
} | ||
|
||
message MembershipUpdate { | ||
repeated Peer peers = 1; | ||
} | ||
|
||
message Peer { | ||
string peer_id = 1; | ||
uint32 latency = 2; // the round trip latency to the peer in milliseconds. | ||
repeated string urls = 3; // url that can be used to connect to the peer. | ||
} | ||
|
||
message CounterUpdate { | ||
bytes key = 1; | ||
map<string, uint64> values = 2; | ||
uint64 expires_at = 3; | ||
} | ||
|
||
// Replication is the limitador replication service. | ||
service Replication { | ||
rpc Stream(stream Packet) returns (stream Packet) {} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably should be conditional on the feature being enabled... see
cfg!
, such as hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do.