Skip to content

Commit 61e5d65

Browse files
committed
Initial attempt at getting protobuf.js loading etcd protos.
0 parents  commit 61e5d65

8 files changed

Lines changed: 411 additions & 0 deletions

File tree

package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "etcd-pump",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "etcd-pump.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "https://archive.voodoowarez.com/etcd-pump.git"
12+
},
13+
"author": "",
14+
"license": "ISC",
15+
"dependencies": {
16+
"es6-promisify": "^3.0.0",
17+
"grpc": "^0.11.1",
18+
"protobufjs": "^4.1.3"
19+
}
20+
}
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
syntax = "proto3";
2+
package etcdserverpb;
3+
4+
import "gogoproto/gogo.proto";
5+
import "etcd/storage/storagepb/kv.proto";
6+
7+
option (gogoproto.marshaler_all) = true;
8+
option (gogoproto.unmarshaler_all) = true;
9+
10+
service KV {
11+
// Range gets the keys in the range from the store.
12+
rpc Range(RangeRequest) returns (RangeResponse) {}
13+
14+
// Put puts the given key into the store.
15+
// A put request increases the revision of the store,
16+
// and generates one event in the event history.
17+
rpc Put(PutRequest) returns (PutResponse) {}
18+
19+
// Delete deletes the given range from the store.
20+
// A delete request increase the revision of the store,
21+
// and generates one event in the event history.
22+
rpc DeleteRange(DeleteRangeRequest) returns (DeleteRangeResponse) {}
23+
24+
// Txn processes all the requests in one transaction.
25+
// A txn request increases the revision of the store,
26+
// and generates events with the same revision in the event history.
27+
rpc Txn(TxnRequest) returns (TxnResponse) {}
28+
29+
// Compact compacts the event history in etcd. User should compact the
30+
// event history periodically, or it will grow infinitely.
31+
rpc Compact(CompactionRequest) returns (CompactionResponse) {}
32+
}
33+
34+
service watch {
35+
// Watch watches the events happening or happened. Both input and output
36+
// are stream. One watch rpc can watch for multiple keys or prefixs and
37+
// get a stream of events. The whole events history can be watched unless
38+
// compacted.
39+
rpc Watch(stream WatchRequest) returns (stream WatchResponse) {}
40+
}
41+
42+
message ResponseHeader {
43+
uint64 cluster_id = 1;
44+
uint64 member_id = 2;
45+
// revision of the store when the request was applied.
46+
int64 revision = 3;
47+
// term of raft when the request was applied.
48+
uint64 raft_term = 4;
49+
}
50+
51+
message RangeRequest {
52+
// if the range_end is not given, the request returns the key.
53+
bytes key = 1;
54+
// if the range_end is given, it gets the keys in range [key, range_end).
55+
bytes range_end = 2;
56+
// limit the number of keys returned.
57+
int64 limit = 3;
58+
// range over the store at the given revision.
59+
// if revision is less or equal to zero, range over the newest store.
60+
// if the revision has been compacted, ErrCompaction will be returned in
61+
// response.
62+
int64 revision = 4;
63+
}
64+
65+
message RangeResponse {
66+
ResponseHeader header = 1;
67+
repeated storagepb.KeyValue kvs = 2;
68+
// more indicates if there are more keys to return in the requested range.
69+
bool more = 3;
70+
}
71+
72+
message PutRequest {
73+
bytes key = 1;
74+
bytes value = 2;
75+
}
76+
77+
message PutResponse {
78+
ResponseHeader header = 1;
79+
}
80+
81+
message DeleteRangeRequest {
82+
// if the range_end is not given, the request deletes the key.
83+
bytes key = 1;
84+
// if the range_end is given, it deletes the keys in range [key, range_end).
85+
bytes range_end = 2;
86+
}
87+
88+
message DeleteRangeResponse {
89+
ResponseHeader header = 1;
90+
}
91+
92+
message RequestUnion {
93+
oneof request {
94+
RangeRequest request_range = 1;
95+
PutRequest request_put = 2;
96+
DeleteRangeRequest request_delete_range = 3;
97+
}
98+
}
99+
100+
message ResponseUnion {
101+
oneof response {
102+
RangeResponse response_range = 1;
103+
PutResponse response_put = 2;
104+
DeleteRangeResponse response_delete_range = 3;
105+
}
106+
}
107+
108+
message Compare {
109+
enum CompareResult {
110+
EQUAL = 0;
111+
GREATER = 1;
112+
LESS = 2;
113+
}
114+
enum CompareTarget {
115+
VERSION = 0;
116+
CREATE = 1;
117+
MOD = 2;
118+
VALUE= 3;
119+
}
120+
CompareResult result = 1;
121+
CompareTarget target = 2;
122+
// key path
123+
bytes key = 3;
124+
oneof target_union {
125+
// version of the given key
126+
int64 version = 4;
127+
// create revision of the given key
128+
int64 create_revision = 5;
129+
// last modified revision of the given key
130+
int64 mod_revision = 6;
131+
// value of the given key
132+
bytes value = 7;
133+
}
134+
}
135+
136+
// If the comparisons succeed, then the success requests will be processed in order,
137+
// and the response will contain their respective responses in order.
138+
// If the comparisons fail, then the failure requests will be processed in order,
139+
// and the response will contain their respective responses in order.
140+
141+
// From google paxosdb paper:
142+
// Our implementation hinges around a powerful primitive which we call MultiOp. All other database
143+
// operations except for iteration are implemented as a single call to MultiOp. A MultiOp is applied atomically
144+
// and consists of three components:
145+
// 1. A list of tests called guard. Each test in guard checks a single entry in the database. It may check
146+
// for the absence or presence of a value, or compare with a given value. Two different tests in the guard
147+
// may apply to the same or different entries in the database. All tests in the guard are applied and
148+
// MultiOp returns the results. If all tests are true, MultiOp executes t op (see item 2 below), otherwise
149+
// it executes f op (see item 3 below).
150+
// 2. A list of database operations called t op. Each operation in the list is either an insert, delete, or
151+
// lookup operation, and applies to a single database entry. Two different operations in the list may apply
152+
// to the same or different entries in the database. These operations are executed
153+
// if guard evaluates to
154+
// true.
155+
// 3. A list of database operations called f op. Like t op, but executed if guard evaluates to false.
156+
message TxnRequest {
157+
repeated Compare compare = 1;
158+
repeated RequestUnion success = 2;
159+
repeated RequestUnion failure = 3;
160+
}
161+
162+
message TxnResponse {
163+
ResponseHeader header = 1;
164+
bool succeeded = 2;
165+
repeated ResponseUnion responses = 3;
166+
}
167+
168+
// Compaction compacts the kv store upto the given revision (including).
169+
// It removes the old versions of a key. It keeps the newest version of
170+
// the key even if its latest modification revision is smaller than the given
171+
// revision.
172+
message CompactionRequest {
173+
int64 revision = 1;
174+
}
175+
176+
message CompactionResponse {
177+
ResponseHeader header = 1;
178+
}
179+
180+
message WatchRequest {
181+
// the key to be watched
182+
bytes key = 1;
183+
// the prefix to be watched.
184+
bytes prefix = 2;
185+
// start_revision is an optional revision (including) to watch from. No start_revision is "now".
186+
int64 start_revision = 3;
187+
// TODO: support Range watch?
188+
// TODO: support notification every time interval or revision increase?
189+
// TODO: support cancel watch if the server cannot reach with majority?
190+
}
191+
192+
message WatchResponse {
193+
ResponseHeader header = 1;
194+
// TODO: support batched events response?
195+
storagepb.Event event = 2;
196+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://raw.githubusercontent.com/coreos/etcd/master/etcdserver/etcdserverpb/rpc.proto

proto/gogoproto/gogo.proto

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved.
2+
// http://github.com/gogo/protobuf/gogoproto
3+
//
4+
// Redistribution and use in source and binary forms, with or without
5+
// modification, are permitted provided that the following conditions are
6+
// met:
7+
//
8+
// * Redistributions of source code must retain the above copyright
9+
// notice, this list of conditions and the following disclaimer.
10+
// * Redistributions in binary form must reproduce the above
11+
// copyright notice, this list of conditions and the following disclaimer
12+
// in the documentation and/or other materials provided with the
13+
// distribution.
14+
//
15+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
27+
syntax = "proto2";
28+
package gogoproto;
29+
30+
import "google/protobuf/descriptor.proto";
31+
32+
option java_package = "com.google.protobuf";
33+
option java_outer_classname = "GoGoProtos";
34+
35+
extend google.protobuf.EnumOptions {
36+
optional bool goproto_enum_prefix = 62001;
37+
optional bool goproto_enum_stringer = 62021;
38+
optional bool enum_stringer = 62022;
39+
}
40+
41+
extend google.protobuf.FileOptions {
42+
optional bool goproto_getters_all = 63001;
43+
optional bool goproto_enum_prefix_all = 63002;
44+
optional bool goproto_stringer_all = 63003;
45+
optional bool verbose_equal_all = 63004;
46+
optional bool face_all = 63005;
47+
optional bool gostring_all = 63006;
48+
optional bool populate_all = 63007;
49+
optional bool stringer_all = 63008;
50+
optional bool onlyone_all = 63009;
51+
52+
optional bool equal_all = 63013;
53+
optional bool description_all = 63014;
54+
optional bool testgen_all = 63015;
55+
optional bool benchgen_all = 63016;
56+
optional bool marshaler_all = 63017;
57+
optional bool unmarshaler_all = 63018;
58+
59+
optional bool sizer_all = 63020;
60+
61+
optional bool goproto_enum_stringer_all = 63021;
62+
optional bool enum_stringer_all = 63022;
63+
64+
optional bool unsafe_marshaler_all = 63023;
65+
optional bool unsafe_unmarshaler_all = 63024;
66+
67+
optional bool goproto_extensions_map_all = 63025;
68+
optional bool goproto_unrecognized_all = 63026;
69+
optional bool gogoproto_import = 63027;
70+
}
71+
72+
extend google.protobuf.MessageOptions {
73+
optional bool goproto_getters = 64001;
74+
optional bool goproto_stringer = 64003;
75+
optional bool verbose_equal = 64004;
76+
optional bool face = 64005;
77+
optional bool gostring = 64006;
78+
optional bool populate = 64007;
79+
optional bool stringer = 67008;
80+
optional bool onlyone = 64009;
81+
82+
optional bool equal = 64013;
83+
optional bool description = 64014;
84+
optional bool testgen = 64015;
85+
optional bool benchgen = 64016;
86+
optional bool marshaler = 64017;
87+
optional bool unmarshaler = 64018;
88+
89+
optional bool sizer = 64020;
90+
91+
optional bool unsafe_marshaler = 64023;
92+
optional bool unsafe_unmarshaler = 64024;
93+
94+
optional bool goproto_extensions_map = 64025;
95+
optional bool goproto_unrecognized = 64026;
96+
}
97+
98+
extend google.protobuf.FieldOptions {
99+
optional bool nullable = 65001;
100+
optional bool embed = 65002;
101+
optional string customtype = 65003;
102+
optional string customname = 65004;
103+
optional string jsontag = 65005;
104+
optional string moretags = 65006;
105+
optional string casttype = 65007;
106+
}
107+

proto/gogoproto/gogo.proto.url

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://raw.githubusercontent.com/gogo/protobuf/master/gogoproto/gogo.proto

proto/storage/storagepb/kv.proto

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
syntax = "proto3";
2+
package storagepb;
3+
4+
import "gogoproto/gogo.proto";
5+
6+
option (gogoproto.marshaler_all) = true;
7+
option (gogoproto.sizer_all) = true;
8+
option (gogoproto.unmarshaler_all) = true;
9+
option (gogoproto.goproto_getters_all) = false;
10+
option (gogoproto.goproto_enum_prefix_all) = false;
11+
12+
message KeyValue {
13+
bytes key = 1;
14+
int64 create_revision = 2;
15+
// mod_revision is the last modified revision of the key.
16+
int64 mod_revision = 3;
17+
// version is the version of the key. A deletion resets
18+
// the version to zero and any modification of the key
19+
// increases its version.
20+
int64 version = 4;
21+
bytes value = 5;
22+
}
23+
24+
message Event {
25+
enum EventType {
26+
PUT = 0;
27+
DELETE = 1;
28+
EXPIRE = 2;
29+
}
30+
EventType type = 1;
31+
// a put event contains the current key-value
32+
// a delete/expire event contains the previous
33+
// key-value
34+
KeyValue kv = 2;
35+
// watchID is the ID of watching this event is sent to.
36+
int64 watchID = 3;
37+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://raw.githubusercontent.com/coreos/etcd/master/storage/storagepb/kv.proto

0 commit comments

Comments
 (0)