dcache/proto/dcache/dcache.proto

168 lines
3.1 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 {
uint64 duration = 502;
Defense defense = 503;
}
message AddCaptchaRequest {
string id = 601;
MCaptcha mcaptcha = 602;
}
message RenameCaptchaRequest {
string name = 701;
string rename_to = 702;
}
message CachePowRequest {
string string= 801;
uint32 difficulty_factor = 802;
uint64 duration = 803;
string key = 804;
}
message CacheResultRequest {
string token = 817;
string key = 818;
uint64 duration= 819;
}
message DeleteCaptchaResultRequest {
string token = 821;
}
message CaptchaID{
string id = 1;
}
message PoID{
string id = 1;
}
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;
}
//message AddVisitorRequest {
// string id = 1;
//}
message DcacheRequest {
oneof DcacheRequest {
AddCaptchaRequest addCaptcha = 1;
CaptchaID addVisitor = 2;
RenameCaptchaRequest renameCaptcha = 3;
CaptchaID removeCaptcha = 4;
CachePowRequest cachePow = 5;
CacheResultRequest cacheResult = 6;
}
}
message DcacheResponse {
oneof DcacheResponse {
OptionAddVisitorResult option_add_visitor_result = 1;
RaftReply other = 2;
}
}
//message DcacheBatchRequest {
// repeated DcacheRequest requests = 1;
//}
//
//message DcacheBatchResponse {
// repeated DcacheResponse responses = 1;
//}
service DcacheService {
rpc AddCaptcha(AddCaptchaRequest) returns (RaftReply) {}
rpc AddVisitor(CaptchaID) returns (OptionAddVisitorResult) {}
rpc RenameCaptcha(RenameCaptchaRequest) returns (RaftReply) {}
rpc RemoveCaptcha(CaptchaID) returns (RaftReply) {}
rpc CachePow(CachePowRequest) returns (RaftReply) {}
rpc CacheResult(CacheResultRequest) returns (RaftReply) {}
// rpc PipelineDcacheOps(DcacheBatchRequest) returns (DcacheBatchResponse) {}
rpc AddLearner(Learner) returns (RaftReply) {}
rpc Write(RaftRequest) returns (RaftReply) {}
/// 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);
//}