dcache/proto/dcache/dcache.proto

139 lines
2.4 KiB
Protocol Buffer

syntax = "proto3";
package dcache;
//message GetRequest { string key = 1; }
//
//message GetReply {
// bool ok = 1;
// string value = 2;
//}
message Level {
uint32 visitor_threshold = 301;
uint32 difficulty_factor= 302;
}
message Defense {
repeated Level levels = 401;
}
message MCaptcha {
uint32 visitor_threshold = 501;
uint64 duration = 502;
Defense defense = 503;
}
message AddCaptcha {
string id = 601;
MCaptcha mcaptcha = 602;
}
message RenameCaptcha {
string name = 701;
string rename_to = 702;
}
message CachePoW {
string string= 801;
uint32 difficulty_factor = 802;
uint64 duration = 803;
string key = 804;
}
message CacheResult {
string token = 817;
string key = 818;
uint64 duration= 819;
}
message DeleteCaptchaResult {
string token = 821;
}
message DcacheRequest {
oneof DcacheRequest {
string AddVisitor = 1;
AddCaptcha add_captcha = 2;
RenameCaptcha rename_captcha = 3;
string remove_captcha = 4;
CachePoW cache_pow = 5;
string delete_pow = 6;
CacheResult cache_result = 7;
DeleteCaptchaResult delete_captcha_result = 8;
}
}
message AddVisitorResult {
uint64 duration = 901;
uint32 difficulty_factor = 902;
}
message OptionAddVisitorResult {
optional AddVisitorResult result = 911;
}
message DcacheResponse {
oneof DcacheResponse {
OptionAddVisitorResult option_add_visitor_result = 1;
uint32 empty = 2;
}
}
message RaftRequest {
string data = 1;
}
message RaftReply {
string data = 1;
string error = 2;
}
//
//message HandshakeRequest {
// uint64 protocol_version = 1;
// bytes payload = 2;
//}
//
//message HandshakeResponse {
// uint64 protocol_version = 1;
// bytes payload = 2;
//}
message Learner {
uint64 id = 1;
string addr = 2;
}
service DcacheService {
rpc AddLearner(Learner) returns (RaftReply) {}
rpc Write(RaftRequest) returns (RaftReply) {}
// rpc Get(GetRequest) returns (GetReply) {}
/// Forward a request to other
rpc Forward(RaftRequest) returns (RaftReply) {}
// raft RPC
rpc AppendEntries(RaftRequest) returns (RaftReply);
rpc InstallSnapshot(RaftRequest) returns (RaftReply);
rpc vote(RaftRequest) returns (RaftReply);
}
//service Dcache {
// // handshake
// rpc Handshake(HandshakeRequest) returns (HandshakeResponse);
//
// // message
// rpc WriteMsg(RaftRequest) returns (RaftReply);
//// rpc ReadMsg(GetRequest) returns (GetReply);
//}