-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #337 from chirino/distributed-grpc
- Loading branch information
Showing
10 changed files
with
985 additions
and
119 deletions.
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.