-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathraft.proto
85 lines (72 loc) · 1.89 KB
/
raft.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
syntax = "proto3";
package raft_pb;
import "google/api/annotations.proto";
import "google/api/http.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
import "protoc-gen-openapiv2/options/openapiv2.proto";
option go_package = "github.com/escalopa/raft-kv/pkg/raft";
service RaftService {
rpc AppendEntries(AppendEntriesRequest) returns (AppendEntriesResponse){
option (google.api.http) = {
post: "/raft/append-entry"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
description: "Append entries to the log"
};
}
rpc RequestVote(RequestVoteRequest) returns (RequestVoteResponse){
option (google.api.http) = {
post: "/raft/vote"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
description: "RequestVote for a candidate"
};
}
rpc Info(InfoRequest) returns (InfoResponse){
option (google.api.http) = {
get: "/raft/info"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
description: "Get Raft node info"
};
}
}
message AppendEntriesRequest{
uint64 term = 1;
uint64 leader_id = 2;
uint64 prev_log_term = 3;
uint64 prev_log_index = 4;
uint64 leader_commit = 5;
repeated Entry entries = 6;
}
message AppendEntriesResponse{
uint64 term = 1;
bool success = 2;
uint64 last_log_index = 3;
}
message RequestVoteRequest {
uint64 term = 1;
uint64 candidate_id = 2;
uint64 last_log_term = 3;
uint64 last_log_index = 4;
}
message RequestVoteResponse {
uint64 term = 1;
bool vote_granted = 2;
}
message InfoRequest {}
message InfoResponse {
uint64 term = 1;
uint64 commit_index = 2;
uint64 last_applied = 3;
uint64 last_log_index = 4;
uint64 last_log_term = 5;
string state = 6;
}
message Entry {
uint64 term = 1;
uint64 index = 2;
repeated string data = 3;
}