-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
Copy pathraft.proto
107 lines (90 loc) · 4.54 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Copyright 2015 The Cockroach Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
//
// Author: Tamir Duberstein ([email protected])
syntax = "proto2";
package cockroach.storage;
option go_package = "storage";
import "cockroach/roachpb/errors.proto";
import "cockroach/roachpb/metadata.proto";
import "etcd/raft/raftpb/raft.proto";
import "gogoproto/gogo.proto";
message RaftHeartbeat {
// TODO(arjun): pare this proto down to the bare necessities.
optional uint64 range_id = 1 [(gogoproto.nullable) = false,
(gogoproto.customname) = "RangeID",
(gogoproto.casttype) = "github.com/cockroachdb/cockroach/roachpb.RangeID"];
optional roachpb.ReplicaDescriptor from_replica = 2 [(gogoproto.nullable) = false];
optional roachpb.ReplicaDescriptor to_replica = 3 [(gogoproto.nullable) = false];
optional uint64 term = 4 [(gogoproto.nullable) = false];
optional uint64 log_term = 5 [(gogoproto.nullable) = false];
optional uint64 commit = 6 [(gogoproto.nullable) = false];
optional bool response = 7 [(gogoproto.nullable) = false];
}
// RaftMessageRequest is the request used to send raft messages using our
// protobuf-based RPC codec.
message RaftMessageRequest {
optional uint64 range_id = 1 [(gogoproto.nullable) = false,
(gogoproto.customname) = "RangeID",
(gogoproto.casttype) = "github.com/cockroachdb/cockroach/roachpb.RangeID"];
optional roachpb.ReplicaDescriptor from_replica = 2 [(gogoproto.nullable) = false];
optional roachpb.ReplicaDescriptor to_replica = 3 [(gogoproto.nullable) = false];
optional raftpb.Message message = 4 [(gogoproto.nullable) = false];
// Is this a quiesce request? A quiesce request is a MsgHeartbeat
// which is requesting the recipient to stop ticking its local
// replica as long as the current Raft state matches the heartbeat
// Term/Commit. If the Term/Commit match, the recipient is marked as
// quiescent. If they don't match, the message is passed along to
// Raft which will generate a MsgHeartbeatResp that will unquiesce
// the sender.
optional bool quiesce = 5 [(gogoproto.nullable) = false];
// A coalesced heartbeat request is any request with a nonzero number of
// coalesced_heartbeats. If this is the case, the message is treated as a
// dummy and discarded. A coalesced heartbeat request's replica descriptor's
// range ID should be zero.
repeated RaftHeartbeat coalesced_heartbeats = 6 [(gogoproto.nullable) = false];
}
message RaftMessageResponseUnion {
option (gogoproto.onlyone) = true;
optional roachpb.Error error = 1;
}
// RaftMessageResponse may be sent to the sender of a
// RaftMessageRequest. RaftMessage does not use the usual
// request/response pattern; it is primarily modeled as a one-way
// stream of requests. Normal 'responses' are usually sent as new
// requests on a separate stream in the other direction.
// RaftMessageResponse is not sent for every RaftMessageRequest, but
// may be used for certain error conditions.
message RaftMessageResponse {
optional uint64 range_id = 1 [(gogoproto.nullable) = false,
(gogoproto.customname) = "RangeID",
(gogoproto.casttype) = "github.com/cockroachdb/cockroach/roachpb.RangeID"];
optional roachpb.ReplicaDescriptor from_replica = 2 [(gogoproto.nullable) = false];
optional roachpb.ReplicaDescriptor to_replica = 3 [(gogoproto.nullable) = false];
optional RaftMessageResponseUnion union = 4 [(gogoproto.nullable) = false];
}
// ConfChangeContext is encoded in the raftpb.ConfChange.Context field.
message ConfChangeContext {
optional string command_id = 1 [(gogoproto.nullable) = false,
(gogoproto.customname) = "CommandID"];
// Payload is the application-level command (i.e. an encoded
// roachpb.EndTransactionRequest).
optional bytes payload = 2;
// Replica contains full details about the replica being added or removed.
optional roachpb.ReplicaDescriptor replica = 3 [(gogoproto.nullable) = false];
}
service MultiRaft {
rpc RaftMessage (stream RaftMessageRequest) returns (stream RaftMessageResponse) {}
rpc RaftMessageSync (RaftMessageRequest) returns (RaftMessageResponse) {}
}