forked from etcd-io/zetcd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
structs.go
211 lines (171 loc) · 4.08 KB
/
structs.go
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
// Copyright 2016 CoreOS, Inc.
//
// 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.
package zetcd
// This file describes the on-wire format.
type Xid int32
type Op int32
type ZXid int64
type Sid int64
type Ver int32 // version
type ACL struct {
Perms int32
Scheme string
ID string
}
type CheckVersionRequest pathVersionRequest
type ConnectRequest struct {
ProtocolVersion int32
LastZxidSeen ZXid
TimeOut int32
SessionID Sid
Passwd []byte
}
type ConnectResponse struct {
ProtocolVersion int32
TimeOut int32
SessionID Sid
Passwd []byte
}
type CreateRequest struct {
Path string
Data []byte
Acl []ACL
Flags int32
}
type CreateResponse pathResponse
type CloseRequest struct{}
type CloseResponse struct{}
type auth struct {
Type int32
Scheme string
Auth []byte
}
type SetAuthRequest auth
type SetAuthResponse struct{}
type SetWatchesRequest struct {
RelativeZxid ZXid
DataWatches []string
ExistWatches []string
ChildWatches []string
}
type SetWatchesResponse struct{}
type MultiHeader struct {
Type Op
Done bool
Err ErrCode
}
type MultiRequestOp struct {
Header MultiHeader
Op interface{}
}
type MultiRequest struct {
Ops []MultiRequestOp
DoneHeader MultiHeader
}
type MultiResponseOp struct {
Header MultiHeader
String string
Stat *Stat
}
type MultiResponse struct {
Ops []MultiResponseOp
DoneHeader MultiHeader
}
type GetChildren2Request pathWatchRequest
type GetChildren2Response struct {
Children []string
Stat Stat
}
type GetDataRequest pathWatchRequest
type GetDataResponse struct {
Data []byte
Stat Stat
}
type DeleteRequest pathVersionRequest
type DeleteResponse struct{}
type ExistsRequest pathWatchRequest
type ExistsResponse statResponse
type GetAclRequest pathRequest
type GetAclResponse struct {
Acl []ACL
Stat Stat
}
type SetAclRequest struct {
Path string
Acl []ACL
Version Ver
}
type SetAclResponse statResponse
type GetChildrenRequest pathWatchRequest
type GetChildrenResponse struct {
Children []string
}
type SyncRequest pathRequest
type SyncResponse pathResponse
type PingRequest struct{}
type PingResponse struct{}
type SetDataRequest struct {
Path string
Data []byte
Version Ver
}
type SetDataResponse statResponse
type Stat struct {
// Czxid is the zxid change that caused this znode to be created.
Czxid ZXid
// Mzxid is The zxid change that last modified this znode.
Mzxid ZXid
// Ctime is milliseconds from epoch when this znode was created.
Ctime int64
// Mtime is The time in milliseconds from epoch when this znode was last modified.
Mtime int64
Version Ver // The number of changes to the data of this znode.
Cversion Ver // The number of changes to the children of this znode.
Aversion Ver // The number of changes to the ACL of this znode.
EphemeralOwner Sid // The session id of the owner of this znode if the znode is an ephemeral node. If it is not an ephemeral node, it will be zero.
DataLength int32 // The length of the data field of this znode.
NumChildren int32 // The number of children of this znode.
Pzxid ZXid // last modified children
}
type WatcherEvent struct {
Type EventType
State State
Path string
}
type pathWatchRequest struct {
Path string
Watch bool
}
type pathResponse struct {
Path string
}
type pathVersionRequest struct {
Path string
Version Ver
}
type statResponse struct {
Stat Stat
}
type requestHeader struct {
Xid Xid
Opcode Op
}
type ResponseHeader struct {
Xid Xid
Zxid ZXid
Err ErrCode
}
type pathRequest struct {
Path string
}