Skip to content
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

Etcdv3 #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ version = "0.3.1"
optional = true
version = "0.2.2"

[dependencies.grpc]
optional = true
version = "0.6.1"

[dependencies.protobuf]
optional = true
version = "~2"

[build-dependencies.protoc-rust-grpc]
optional = true
version = "0.6.1"

[features]
default = ["tls"]
tls = ["hyper-tls", "native-tls"]
v3 = ["grpc", "protobuf", "protoc-rust-grpc"]
18 changes: 18 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
fn main() {
gen_proto();
}

#[cfg(feature = "v3")]
fn gen_proto() {
protoc_rust_grpc::run(protoc_rust_grpc::Args {
out_dir: "src/v3",
includes: &["proto"],
input: &["proto/rpc.proto", "proto/auth.proto", "proto/kv.proto"],
rust_protobuf: true,
..Default::default()
})
.expect("protoc-rust-grpc failed");
}

#[cfg(not(feature = "v3"))]
fn gen_proto() {}
31 changes: 31 additions & 0 deletions proto/auth.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
syntax = "proto3";
package authpb;



// User is a single entry in the bucket authUsers
message User {
bytes name = 1;
bytes password = 2;
repeated string roles = 3;
}

// Permission is a single entity
message Permission {
enum Type {
READ = 0;
WRITE = 1;
READWRITE = 2;
}
Type permType = 1;

bytes key = 2;
bytes range_end = 3;
}

// Role is a single entry in the bucket authRoles
message Role {
bytes name = 1;

repeated Permission keyPermission = 2;
}
43 changes: 43 additions & 0 deletions proto/kv.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
syntax = "proto3";
package mvccpb;



message KeyValue {
// key is the key in bytes. An empty key is not allowed.
bytes key = 1;
// create_revision is the revision of last creation on this key.
int64 create_revision = 2;
// mod_revision is the revision of last modification on this key.
int64 mod_revision = 3;
// version is the version of the key. A deletion resets
// the version to zero and any modification of the key
// increases its version.
int64 version = 4;
// value is the value held by the key, in bytes.
bytes value = 5;
// lease is the ID of the lease that attached to key.
// When the attached lease expires, the key will be deleted.
// If lease is 0, then no lease is attached to the key.
int64 lease = 6;
}

message Event {
enum EventType {
PUT = 0;
DELETE = 1;
}
// type is the kind of event. If type is a PUT, it indicates
// new data has been stored to the key. If type is a DELETE,
// it indicates the key was deleted.
EventType type = 1;
// kv holds the KeyValue for the event.
// A PUT event contains current kv pair.
// A PUT event with kv.Version=1 indicates the creation of a key.
// A DELETE/EXPIRE event contains the deleted key with
// its modification revision set to the revision of deletion.
KeyValue kv = 2;

// prev_kv holds the key-value pair before the event happens.
KeyValue prev_kv = 3;
}
Loading