Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 1 | // Copyright 2015 The Vanadium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | // This file was auto-generated by the vanadium vdl tool. |
| 6 | // Source: sync.vdl |
| 7 | |
Himabindu Pucha | f9ec56f | 2015-06-02 11:34:05 -0700 | [diff] [blame] | 8 | package interfaces |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 9 | |
| 10 | import ( |
| 11 | // VDL system imports |
Himabindu Pucha | 03ef393 | 2015-06-26 17:56:09 -0700 | [diff] [blame] | 12 | "io" |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 13 | "v.io/v23" |
| 14 | "v.io/v23/context" |
Raja Daoud | 5285136 | 2015-09-14 15:50:40 -0700 | [diff] [blame^] | 15 | "v.io/v23/i18n" |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 16 | "v.io/v23/rpc" |
Sergey Rogulenko | c2e60f6 | 2015-06-23 14:50:58 -0700 | [diff] [blame] | 17 | "v.io/v23/vdl" |
Raja Daoud | 5285136 | 2015-09-14 15:50:40 -0700 | [diff] [blame^] | 18 | "v.io/v23/verror" |
Himabindu Pucha | 12e1a12 | 2015-06-08 15:59:09 -0700 | [diff] [blame] | 19 | |
| 20 | // VDL user imports |
Sergey Rogulenko | c2e60f6 | 2015-06-23 14:50:58 -0700 | [diff] [blame] | 21 | "v.io/v23/security/access" |
Adam Sadovsky | f2efeb5 | 2015-08-31 14:17:49 -0700 | [diff] [blame] | 22 | "v.io/v23/services/syncbase/nosql" |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 23 | ) |
| 24 | |
Raja Daoud | 5285136 | 2015-09-14 15:50:40 -0700 | [diff] [blame^] | 25 | var ( |
| 26 | ErrDupSyncGroupPublish = verror.Register("v.io/x/ref/services/syncbase/server/interfaces.DupSyncGroupPublish", verror.NoRetry, "{1:}{2:} duplicate publish on SyncGroup: {3}") |
| 27 | ) |
| 28 | |
| 29 | func init() { |
| 30 | i18n.Cat().SetWithBase(i18n.LangID("en"), i18n.MsgID(ErrDupSyncGroupPublish.ID), "{1:}{2:} duplicate publish on SyncGroup: {3}") |
| 31 | } |
| 32 | |
| 33 | // NewErrDupSyncGroupPublish returns an error with the ErrDupSyncGroupPublish ID. |
| 34 | func NewErrDupSyncGroupPublish(ctx *context.T, name string) error { |
| 35 | return verror.New(ErrDupSyncGroupPublish, ctx, name) |
| 36 | } |
| 37 | |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 38 | // SyncClientMethods is the client interface |
| 39 | // containing Sync methods. |
| 40 | // |
| 41 | // Sync defines methods for data exchange between Syncbases. |
| 42 | // TODO(hpucha): Flesh this out further. |
| 43 | type SyncClientMethods interface { |
Himabindu Pucha | 03ef393 | 2015-06-26 17:56:09 -0700 | [diff] [blame] | 44 | // GetDeltas returns the responder's current generation vector and all |
| 45 | // the missing log records when compared to the initiator's generation |
Himabindu Pucha | b41fc14 | 2015-09-10 17:10:57 -0700 | [diff] [blame] | 46 | // vector for one Database for either SyncGroup metadata or data. |
| 47 | GetDeltas(ctx *context.T, req DeltaReq, initiator string, opts ...rpc.CallOpt) (SyncGetDeltasClientCall, error) |
Raja Daoud | 5285136 | 2015-09-14 15:50:40 -0700 | [diff] [blame^] | 48 | // PublishSyncGroup is invoked on the SyncGroup name (typically served |
| 49 | // by a "central" peer) to publish the SyncGroup. It takes the name of |
| 50 | // Syncbase doing the publishing (the publisher) and returns the name |
| 51 | // of the Syncbase where the SyncGroup is published (the publishee). |
| 52 | // This allows the publisher and the publishee to learn of each other. |
| 53 | // When a SyncGroup is published, the publishee is given the SyncGroup |
| 54 | // metadata, its current version at the publisher, and the current |
| 55 | // SyncGroup generation vector. The generation vector serves as a |
| 56 | // checkpoint at the time of publishing. The publishing proceeds |
| 57 | // asynchronously, and the publishee learns the SyncGroup history |
| 58 | // through the routine p2p sync process and determines when it has |
| 59 | // caught up to the level of knowledge at the time of publishing using |
| 60 | // the checkpointed generation vector. Until that point, the publishee |
| 61 | // locally deems the SyncGroup to be in a pending state and does not |
| 62 | // mutate it. Thus it locally rejects SyncGroup joins or updates to |
| 63 | // its spec until it is caught up on the SyncGroup history. |
| 64 | PublishSyncGroup(ctx *context.T, publisher string, sg SyncGroup, version string, genvec PrefixGenVector, opts ...rpc.CallOpt) (string, error) |
Himabindu Pucha | 12e1a12 | 2015-06-08 15:59:09 -0700 | [diff] [blame] | 65 | // JoinSyncGroupAtAdmin is invoked by a prospective SyncGroup member's |
| 66 | // Syncbase on a SyncGroup admin. It checks whether the requestor is |
| 67 | // allowed to join the named SyncGroup, and if so, adds the requestor to |
Raja Daoud | 5285136 | 2015-09-14 15:50:40 -0700 | [diff] [blame^] | 68 | // the SyncGroup. It returns a copy of the updated SyncGroup metadata, |
| 69 | // its version, and the SyncGroup generation vector at the time of the |
| 70 | // join. Similar to the PublishSyncGroup scenario, the joiner at that |
| 71 | // point does not have the SyncGroup history and locally deems it to be |
| 72 | // in a pending state and does not mutate it. This means it rejects |
| 73 | // local updates to the SyncGroup spec or, if it were also an admin on |
| 74 | // the SyncGroup, it would reject SyncGroup joins until it is caught up |
| 75 | // on the SyncGroup history through p2p sync. |
| 76 | JoinSyncGroupAtAdmin(ctx *context.T, sgName string, joinerName string, myInfo nosql.SyncGroupMemberInfo, opts ...rpc.CallOpt) (sg SyncGroup, version string, genvec PrefixGenVector, err error) |
Himabindu Pucha | 665f14c | 2015-08-13 13:42:01 -0700 | [diff] [blame] | 77 | // HaveBlob verifies that the peer has the requested blob, and if |
| 78 | // present, returns its size. |
| 79 | HaveBlob(ctx *context.T, br nosql.BlobRef, opts ...rpc.CallOpt) (int64, error) |
| 80 | // FetchBlob fetches the requested blob. |
| 81 | FetchBlob(ctx *context.T, br nosql.BlobRef, opts ...rpc.CallOpt) (SyncFetchBlobClientCall, error) |
| 82 | // Methods for incremental blob transfer. The transfer starts with the |
| 83 | // receiver making a FetchBlobRecipe call to the sender for a given |
| 84 | // BlobRef. The sender, in turn, sends the chunk hashes of all the |
| 85 | // chunks that make up the requested blob (blob recipe). The receiver |
| 86 | // looks up the chunk hashes in its local blob store, and identifies the |
| 87 | // missing ones. The receiver then fetches the missing chunks using a |
| 88 | // FetchChunks call from the sender. Finally, the receiver finishes the |
| 89 | // blob fetch by combining the chunks obtained over the network with the |
| 90 | // already available local chunks as per the blob recipe. |
| 91 | FetchBlobRecipe(ctx *context.T, br nosql.BlobRef, opts ...rpc.CallOpt) (SyncFetchBlobRecipeClientCall, error) |
| 92 | FetchChunks(*context.T, ...rpc.CallOpt) (SyncFetchChunksClientCall, error) |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | // SyncClientStub adds universal methods to SyncClientMethods. |
| 96 | type SyncClientStub interface { |
| 97 | SyncClientMethods |
| 98 | rpc.UniversalServiceMethods |
| 99 | } |
| 100 | |
| 101 | // SyncClient returns a client stub for Sync. |
| 102 | func SyncClient(name string) SyncClientStub { |
| 103 | return implSyncClientStub{name} |
| 104 | } |
| 105 | |
| 106 | type implSyncClientStub struct { |
| 107 | name string |
| 108 | } |
| 109 | |
Himabindu Pucha | b41fc14 | 2015-09-10 17:10:57 -0700 | [diff] [blame] | 110 | func (c implSyncClientStub) GetDeltas(ctx *context.T, i0 DeltaReq, i1 string, opts ...rpc.CallOpt) (ocall SyncGetDeltasClientCall, err error) { |
Himabindu Pucha | 03ef393 | 2015-06-26 17:56:09 -0700 | [diff] [blame] | 111 | var call rpc.ClientCall |
Himabindu Pucha | b41fc14 | 2015-09-10 17:10:57 -0700 | [diff] [blame] | 112 | if call, err = v23.GetClient(ctx).StartCall(ctx, c.name, "GetDeltas", []interface{}{i0, i1}, opts...); err != nil { |
Himabindu Pucha | 03ef393 | 2015-06-26 17:56:09 -0700 | [diff] [blame] | 113 | return |
| 114 | } |
| 115 | ocall = &implSyncGetDeltasClientCall{ClientCall: call} |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 116 | return |
| 117 | } |
| 118 | |
Raja Daoud | 5285136 | 2015-09-14 15:50:40 -0700 | [diff] [blame^] | 119 | func (c implSyncClientStub) PublishSyncGroup(ctx *context.T, i0 string, i1 SyncGroup, i2 string, i3 PrefixGenVector, opts ...rpc.CallOpt) (o0 string, err error) { |
| 120 | err = v23.GetClient(ctx).Call(ctx, c.name, "PublishSyncGroup", []interface{}{i0, i1, i2, i3}, []interface{}{&o0}, opts...) |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 121 | return |
| 122 | } |
| 123 | |
Raja Daoud | 5285136 | 2015-09-14 15:50:40 -0700 | [diff] [blame^] | 124 | func (c implSyncClientStub) JoinSyncGroupAtAdmin(ctx *context.T, i0 string, i1 string, i2 nosql.SyncGroupMemberInfo, opts ...rpc.CallOpt) (o0 SyncGroup, o1 string, o2 PrefixGenVector, err error) { |
| 125 | err = v23.GetClient(ctx).Call(ctx, c.name, "JoinSyncGroupAtAdmin", []interface{}{i0, i1, i2}, []interface{}{&o0, &o1, &o2}, opts...) |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 126 | return |
| 127 | } |
| 128 | |
Himabindu Pucha | 665f14c | 2015-08-13 13:42:01 -0700 | [diff] [blame] | 129 | func (c implSyncClientStub) HaveBlob(ctx *context.T, i0 nosql.BlobRef, opts ...rpc.CallOpt) (o0 int64, err error) { |
| 130 | err = v23.GetClient(ctx).Call(ctx, c.name, "HaveBlob", []interface{}{i0}, []interface{}{&o0}, opts...) |
| 131 | return |
| 132 | } |
| 133 | |
| 134 | func (c implSyncClientStub) FetchBlob(ctx *context.T, i0 nosql.BlobRef, opts ...rpc.CallOpt) (ocall SyncFetchBlobClientCall, err error) { |
| 135 | var call rpc.ClientCall |
| 136 | if call, err = v23.GetClient(ctx).StartCall(ctx, c.name, "FetchBlob", []interface{}{i0}, opts...); err != nil { |
| 137 | return |
| 138 | } |
| 139 | ocall = &implSyncFetchBlobClientCall{ClientCall: call} |
| 140 | return |
| 141 | } |
| 142 | |
| 143 | func (c implSyncClientStub) FetchBlobRecipe(ctx *context.T, i0 nosql.BlobRef, opts ...rpc.CallOpt) (ocall SyncFetchBlobRecipeClientCall, err error) { |
| 144 | var call rpc.ClientCall |
| 145 | if call, err = v23.GetClient(ctx).StartCall(ctx, c.name, "FetchBlobRecipe", []interface{}{i0}, opts...); err != nil { |
| 146 | return |
| 147 | } |
| 148 | ocall = &implSyncFetchBlobRecipeClientCall{ClientCall: call} |
| 149 | return |
| 150 | } |
| 151 | |
| 152 | func (c implSyncClientStub) FetchChunks(ctx *context.T, opts ...rpc.CallOpt) (ocall SyncFetchChunksClientCall, err error) { |
| 153 | var call rpc.ClientCall |
| 154 | if call, err = v23.GetClient(ctx).StartCall(ctx, c.name, "FetchChunks", nil, opts...); err != nil { |
| 155 | return |
| 156 | } |
| 157 | ocall = &implSyncFetchChunksClientCall{ClientCall: call} |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 158 | return |
| 159 | } |
| 160 | |
Himabindu Pucha | 03ef393 | 2015-06-26 17:56:09 -0700 | [diff] [blame] | 161 | // SyncGetDeltasClientStream is the client stream for Sync.GetDeltas. |
| 162 | type SyncGetDeltasClientStream interface { |
| 163 | // RecvStream returns the receiver side of the Sync.GetDeltas client stream. |
| 164 | RecvStream() interface { |
| 165 | // Advance stages an item so that it may be retrieved via Value. Returns |
| 166 | // true iff there is an item to retrieve. Advance must be called before |
| 167 | // Value is called. May block if an item is not available. |
| 168 | Advance() bool |
| 169 | // Value returns the item that was staged by Advance. May panic if Advance |
| 170 | // returned false or was not called. Never blocks. |
| 171 | Value() DeltaResp |
| 172 | // Err returns any error encountered by Advance. Never blocks. |
| 173 | Err() error |
| 174 | } |
Himabindu Pucha | 03ef393 | 2015-06-26 17:56:09 -0700 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | // SyncGetDeltasClientCall represents the call returned from Sync.GetDeltas. |
| 178 | type SyncGetDeltasClientCall interface { |
| 179 | SyncGetDeltasClientStream |
Himabindu Pucha | b41fc14 | 2015-09-10 17:10:57 -0700 | [diff] [blame] | 180 | // Finish blocks until the server is done, and returns the positional return |
| 181 | // values for call. |
Himabindu Pucha | 03ef393 | 2015-06-26 17:56:09 -0700 | [diff] [blame] | 182 | // |
| 183 | // Finish returns immediately if the call has been canceled; depending on the |
| 184 | // timing the output could either be an error signaling cancelation, or the |
| 185 | // valid positional return values from the server. |
| 186 | // |
| 187 | // Calling Finish is mandatory for releasing stream resources, unless the call |
| 188 | // has been canceled or any of the other methods return an error. Finish should |
| 189 | // be called at most once. |
| 190 | Finish() error |
| 191 | } |
| 192 | |
| 193 | type implSyncGetDeltasClientCall struct { |
| 194 | rpc.ClientCall |
| 195 | valRecv DeltaResp |
| 196 | errRecv error |
| 197 | } |
| 198 | |
| 199 | func (c *implSyncGetDeltasClientCall) RecvStream() interface { |
| 200 | Advance() bool |
| 201 | Value() DeltaResp |
| 202 | Err() error |
| 203 | } { |
| 204 | return implSyncGetDeltasClientCallRecv{c} |
| 205 | } |
| 206 | |
| 207 | type implSyncGetDeltasClientCallRecv struct { |
| 208 | c *implSyncGetDeltasClientCall |
| 209 | } |
| 210 | |
| 211 | func (c implSyncGetDeltasClientCallRecv) Advance() bool { |
| 212 | c.c.errRecv = c.c.Recv(&c.c.valRecv) |
| 213 | return c.c.errRecv == nil |
| 214 | } |
| 215 | func (c implSyncGetDeltasClientCallRecv) Value() DeltaResp { |
| 216 | return c.c.valRecv |
| 217 | } |
| 218 | func (c implSyncGetDeltasClientCallRecv) Err() error { |
| 219 | if c.c.errRecv == io.EOF { |
| 220 | return nil |
| 221 | } |
| 222 | return c.c.errRecv |
| 223 | } |
Himabindu Pucha | 03ef393 | 2015-06-26 17:56:09 -0700 | [diff] [blame] | 224 | func (c *implSyncGetDeltasClientCall) Finish() (err error) { |
| 225 | err = c.ClientCall.Finish() |
| 226 | return |
| 227 | } |
| 228 | |
Himabindu Pucha | 665f14c | 2015-08-13 13:42:01 -0700 | [diff] [blame] | 229 | // SyncFetchBlobClientStream is the client stream for Sync.FetchBlob. |
| 230 | type SyncFetchBlobClientStream interface { |
| 231 | // RecvStream returns the receiver side of the Sync.FetchBlob client stream. |
| 232 | RecvStream() interface { |
| 233 | // Advance stages an item so that it may be retrieved via Value. Returns |
| 234 | // true iff there is an item to retrieve. Advance must be called before |
| 235 | // Value is called. May block if an item is not available. |
| 236 | Advance() bool |
| 237 | // Value returns the item that was staged by Advance. May panic if Advance |
| 238 | // returned false or was not called. Never blocks. |
| 239 | Value() []byte |
| 240 | // Err returns any error encountered by Advance. Never blocks. |
| 241 | Err() error |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | // SyncFetchBlobClientCall represents the call returned from Sync.FetchBlob. |
| 246 | type SyncFetchBlobClientCall interface { |
| 247 | SyncFetchBlobClientStream |
| 248 | // Finish blocks until the server is done, and returns the positional return |
| 249 | // values for call. |
| 250 | // |
| 251 | // Finish returns immediately if the call has been canceled; depending on the |
| 252 | // timing the output could either be an error signaling cancelation, or the |
| 253 | // valid positional return values from the server. |
| 254 | // |
| 255 | // Calling Finish is mandatory for releasing stream resources, unless the call |
| 256 | // has been canceled or any of the other methods return an error. Finish should |
| 257 | // be called at most once. |
| 258 | Finish() error |
| 259 | } |
| 260 | |
| 261 | type implSyncFetchBlobClientCall struct { |
| 262 | rpc.ClientCall |
| 263 | valRecv []byte |
| 264 | errRecv error |
| 265 | } |
| 266 | |
| 267 | func (c *implSyncFetchBlobClientCall) RecvStream() interface { |
| 268 | Advance() bool |
| 269 | Value() []byte |
| 270 | Err() error |
| 271 | } { |
| 272 | return implSyncFetchBlobClientCallRecv{c} |
| 273 | } |
| 274 | |
| 275 | type implSyncFetchBlobClientCallRecv struct { |
| 276 | c *implSyncFetchBlobClientCall |
| 277 | } |
| 278 | |
| 279 | func (c implSyncFetchBlobClientCallRecv) Advance() bool { |
| 280 | c.c.errRecv = c.c.Recv(&c.c.valRecv) |
| 281 | return c.c.errRecv == nil |
| 282 | } |
| 283 | func (c implSyncFetchBlobClientCallRecv) Value() []byte { |
| 284 | return c.c.valRecv |
| 285 | } |
| 286 | func (c implSyncFetchBlobClientCallRecv) Err() error { |
| 287 | if c.c.errRecv == io.EOF { |
| 288 | return nil |
| 289 | } |
| 290 | return c.c.errRecv |
| 291 | } |
| 292 | func (c *implSyncFetchBlobClientCall) Finish() (err error) { |
| 293 | err = c.ClientCall.Finish() |
| 294 | return |
| 295 | } |
| 296 | |
| 297 | // SyncFetchBlobRecipeClientStream is the client stream for Sync.FetchBlobRecipe. |
| 298 | type SyncFetchBlobRecipeClientStream interface { |
| 299 | // RecvStream returns the receiver side of the Sync.FetchBlobRecipe client stream. |
| 300 | RecvStream() interface { |
| 301 | // Advance stages an item so that it may be retrieved via Value. Returns |
| 302 | // true iff there is an item to retrieve. Advance must be called before |
| 303 | // Value is called. May block if an item is not available. |
| 304 | Advance() bool |
| 305 | // Value returns the item that was staged by Advance. May panic if Advance |
| 306 | // returned false or was not called. Never blocks. |
| 307 | Value() ChunkHash |
| 308 | // Err returns any error encountered by Advance. Never blocks. |
| 309 | Err() error |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | // SyncFetchBlobRecipeClientCall represents the call returned from Sync.FetchBlobRecipe. |
| 314 | type SyncFetchBlobRecipeClientCall interface { |
| 315 | SyncFetchBlobRecipeClientStream |
| 316 | // Finish blocks until the server is done, and returns the positional return |
| 317 | // values for call. |
| 318 | // |
| 319 | // Finish returns immediately if the call has been canceled; depending on the |
| 320 | // timing the output could either be an error signaling cancelation, or the |
| 321 | // valid positional return values from the server. |
| 322 | // |
| 323 | // Calling Finish is mandatory for releasing stream resources, unless the call |
| 324 | // has been canceled or any of the other methods return an error. Finish should |
| 325 | // be called at most once. |
| 326 | Finish() error |
| 327 | } |
| 328 | |
| 329 | type implSyncFetchBlobRecipeClientCall struct { |
| 330 | rpc.ClientCall |
| 331 | valRecv ChunkHash |
| 332 | errRecv error |
| 333 | } |
| 334 | |
| 335 | func (c *implSyncFetchBlobRecipeClientCall) RecvStream() interface { |
| 336 | Advance() bool |
| 337 | Value() ChunkHash |
| 338 | Err() error |
| 339 | } { |
| 340 | return implSyncFetchBlobRecipeClientCallRecv{c} |
| 341 | } |
| 342 | |
| 343 | type implSyncFetchBlobRecipeClientCallRecv struct { |
| 344 | c *implSyncFetchBlobRecipeClientCall |
| 345 | } |
| 346 | |
| 347 | func (c implSyncFetchBlobRecipeClientCallRecv) Advance() bool { |
| 348 | c.c.valRecv = ChunkHash{} |
| 349 | c.c.errRecv = c.c.Recv(&c.c.valRecv) |
| 350 | return c.c.errRecv == nil |
| 351 | } |
| 352 | func (c implSyncFetchBlobRecipeClientCallRecv) Value() ChunkHash { |
| 353 | return c.c.valRecv |
| 354 | } |
| 355 | func (c implSyncFetchBlobRecipeClientCallRecv) Err() error { |
| 356 | if c.c.errRecv == io.EOF { |
| 357 | return nil |
| 358 | } |
| 359 | return c.c.errRecv |
| 360 | } |
| 361 | func (c *implSyncFetchBlobRecipeClientCall) Finish() (err error) { |
| 362 | err = c.ClientCall.Finish() |
| 363 | return |
| 364 | } |
| 365 | |
| 366 | // SyncFetchChunksClientStream is the client stream for Sync.FetchChunks. |
| 367 | type SyncFetchChunksClientStream interface { |
| 368 | // RecvStream returns the receiver side of the Sync.FetchChunks client stream. |
| 369 | RecvStream() interface { |
| 370 | // Advance stages an item so that it may be retrieved via Value. Returns |
| 371 | // true iff there is an item to retrieve. Advance must be called before |
| 372 | // Value is called. May block if an item is not available. |
| 373 | Advance() bool |
| 374 | // Value returns the item that was staged by Advance. May panic if Advance |
| 375 | // returned false or was not called. Never blocks. |
| 376 | Value() ChunkData |
| 377 | // Err returns any error encountered by Advance. Never blocks. |
| 378 | Err() error |
| 379 | } |
| 380 | // SendStream returns the send side of the Sync.FetchChunks client stream. |
| 381 | SendStream() interface { |
| 382 | // Send places the item onto the output stream. Returns errors |
| 383 | // encountered while sending, or if Send is called after Close or |
| 384 | // the stream has been canceled. Blocks if there is no buffer |
| 385 | // space; will unblock when buffer space is available or after |
| 386 | // the stream has been canceled. |
| 387 | Send(item ChunkHash) error |
| 388 | // Close indicates to the server that no more items will be sent; |
| 389 | // server Recv calls will receive io.EOF after all sent items. |
| 390 | // This is an optional call - e.g. a client might call Close if it |
| 391 | // needs to continue receiving items from the server after it's |
| 392 | // done sending. Returns errors encountered while closing, or if |
| 393 | // Close is called after the stream has been canceled. Like Send, |
| 394 | // blocks if there is no buffer space available. |
| 395 | Close() error |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | // SyncFetchChunksClientCall represents the call returned from Sync.FetchChunks. |
| 400 | type SyncFetchChunksClientCall interface { |
| 401 | SyncFetchChunksClientStream |
| 402 | // Finish performs the equivalent of SendStream().Close, then blocks until |
| 403 | // the server is done, and returns the positional return values for the call. |
| 404 | // |
| 405 | // Finish returns immediately if the call has been canceled; depending on the |
| 406 | // timing the output could either be an error signaling cancelation, or the |
| 407 | // valid positional return values from the server. |
| 408 | // |
| 409 | // Calling Finish is mandatory for releasing stream resources, unless the call |
| 410 | // has been canceled or any of the other methods return an error. Finish should |
| 411 | // be called at most once. |
| 412 | Finish() error |
| 413 | } |
| 414 | |
| 415 | type implSyncFetchChunksClientCall struct { |
| 416 | rpc.ClientCall |
| 417 | valRecv ChunkData |
| 418 | errRecv error |
| 419 | } |
| 420 | |
| 421 | func (c *implSyncFetchChunksClientCall) RecvStream() interface { |
| 422 | Advance() bool |
| 423 | Value() ChunkData |
| 424 | Err() error |
| 425 | } { |
| 426 | return implSyncFetchChunksClientCallRecv{c} |
| 427 | } |
| 428 | |
| 429 | type implSyncFetchChunksClientCallRecv struct { |
| 430 | c *implSyncFetchChunksClientCall |
| 431 | } |
| 432 | |
| 433 | func (c implSyncFetchChunksClientCallRecv) Advance() bool { |
| 434 | c.c.valRecv = ChunkData{} |
| 435 | c.c.errRecv = c.c.Recv(&c.c.valRecv) |
| 436 | return c.c.errRecv == nil |
| 437 | } |
| 438 | func (c implSyncFetchChunksClientCallRecv) Value() ChunkData { |
| 439 | return c.c.valRecv |
| 440 | } |
| 441 | func (c implSyncFetchChunksClientCallRecv) Err() error { |
| 442 | if c.c.errRecv == io.EOF { |
| 443 | return nil |
| 444 | } |
| 445 | return c.c.errRecv |
| 446 | } |
| 447 | func (c *implSyncFetchChunksClientCall) SendStream() interface { |
| 448 | Send(item ChunkHash) error |
| 449 | Close() error |
| 450 | } { |
| 451 | return implSyncFetchChunksClientCallSend{c} |
| 452 | } |
| 453 | |
| 454 | type implSyncFetchChunksClientCallSend struct { |
| 455 | c *implSyncFetchChunksClientCall |
| 456 | } |
| 457 | |
| 458 | func (c implSyncFetchChunksClientCallSend) Send(item ChunkHash) error { |
| 459 | return c.c.Send(item) |
| 460 | } |
| 461 | func (c implSyncFetchChunksClientCallSend) Close() error { |
| 462 | return c.c.CloseSend() |
| 463 | } |
| 464 | func (c *implSyncFetchChunksClientCall) Finish() (err error) { |
| 465 | err = c.ClientCall.Finish() |
| 466 | return |
| 467 | } |
| 468 | |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 469 | // SyncServerMethods is the interface a server writer |
| 470 | // implements for Sync. |
| 471 | // |
| 472 | // Sync defines methods for data exchange between Syncbases. |
| 473 | // TODO(hpucha): Flesh this out further. |
| 474 | type SyncServerMethods interface { |
Himabindu Pucha | 03ef393 | 2015-06-26 17:56:09 -0700 | [diff] [blame] | 475 | // GetDeltas returns the responder's current generation vector and all |
| 476 | // the missing log records when compared to the initiator's generation |
Himabindu Pucha | b41fc14 | 2015-09-10 17:10:57 -0700 | [diff] [blame] | 477 | // vector for one Database for either SyncGroup metadata or data. |
| 478 | GetDeltas(ctx *context.T, call SyncGetDeltasServerCall, req DeltaReq, initiator string) error |
Raja Daoud | 5285136 | 2015-09-14 15:50:40 -0700 | [diff] [blame^] | 479 | // PublishSyncGroup is invoked on the SyncGroup name (typically served |
| 480 | // by a "central" peer) to publish the SyncGroup. It takes the name of |
| 481 | // Syncbase doing the publishing (the publisher) and returns the name |
| 482 | // of the Syncbase where the SyncGroup is published (the publishee). |
| 483 | // This allows the publisher and the publishee to learn of each other. |
| 484 | // When a SyncGroup is published, the publishee is given the SyncGroup |
| 485 | // metadata, its current version at the publisher, and the current |
| 486 | // SyncGroup generation vector. The generation vector serves as a |
| 487 | // checkpoint at the time of publishing. The publishing proceeds |
| 488 | // asynchronously, and the publishee learns the SyncGroup history |
| 489 | // through the routine p2p sync process and determines when it has |
| 490 | // caught up to the level of knowledge at the time of publishing using |
| 491 | // the checkpointed generation vector. Until that point, the publishee |
| 492 | // locally deems the SyncGroup to be in a pending state and does not |
| 493 | // mutate it. Thus it locally rejects SyncGroup joins or updates to |
| 494 | // its spec until it is caught up on the SyncGroup history. |
| 495 | PublishSyncGroup(ctx *context.T, call rpc.ServerCall, publisher string, sg SyncGroup, version string, genvec PrefixGenVector) (string, error) |
Himabindu Pucha | 12e1a12 | 2015-06-08 15:59:09 -0700 | [diff] [blame] | 496 | // JoinSyncGroupAtAdmin is invoked by a prospective SyncGroup member's |
| 497 | // Syncbase on a SyncGroup admin. It checks whether the requestor is |
| 498 | // allowed to join the named SyncGroup, and if so, adds the requestor to |
Raja Daoud | 5285136 | 2015-09-14 15:50:40 -0700 | [diff] [blame^] | 499 | // the SyncGroup. It returns a copy of the updated SyncGroup metadata, |
| 500 | // its version, and the SyncGroup generation vector at the time of the |
| 501 | // join. Similar to the PublishSyncGroup scenario, the joiner at that |
| 502 | // point does not have the SyncGroup history and locally deems it to be |
| 503 | // in a pending state and does not mutate it. This means it rejects |
| 504 | // local updates to the SyncGroup spec or, if it were also an admin on |
| 505 | // the SyncGroup, it would reject SyncGroup joins until it is caught up |
| 506 | // on the SyncGroup history through p2p sync. |
| 507 | JoinSyncGroupAtAdmin(ctx *context.T, call rpc.ServerCall, sgName string, joinerName string, myInfo nosql.SyncGroupMemberInfo) (sg SyncGroup, version string, genvec PrefixGenVector, err error) |
Himabindu Pucha | 665f14c | 2015-08-13 13:42:01 -0700 | [diff] [blame] | 508 | // HaveBlob verifies that the peer has the requested blob, and if |
| 509 | // present, returns its size. |
| 510 | HaveBlob(ctx *context.T, call rpc.ServerCall, br nosql.BlobRef) (int64, error) |
| 511 | // FetchBlob fetches the requested blob. |
| 512 | FetchBlob(ctx *context.T, call SyncFetchBlobServerCall, br nosql.BlobRef) error |
| 513 | // Methods for incremental blob transfer. The transfer starts with the |
| 514 | // receiver making a FetchBlobRecipe call to the sender for a given |
| 515 | // BlobRef. The sender, in turn, sends the chunk hashes of all the |
| 516 | // chunks that make up the requested blob (blob recipe). The receiver |
| 517 | // looks up the chunk hashes in its local blob store, and identifies the |
| 518 | // missing ones. The receiver then fetches the missing chunks using a |
| 519 | // FetchChunks call from the sender. Finally, the receiver finishes the |
| 520 | // blob fetch by combining the chunks obtained over the network with the |
| 521 | // already available local chunks as per the blob recipe. |
| 522 | FetchBlobRecipe(ctx *context.T, call SyncFetchBlobRecipeServerCall, br nosql.BlobRef) error |
| 523 | FetchChunks(*context.T, SyncFetchChunksServerCall) error |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | // SyncServerStubMethods is the server interface containing |
| 527 | // Sync methods, as expected by rpc.Server. |
Himabindu Pucha | 03ef393 | 2015-06-26 17:56:09 -0700 | [diff] [blame] | 528 | // The only difference between this interface and SyncServerMethods |
| 529 | // is the streaming methods. |
| 530 | type SyncServerStubMethods interface { |
| 531 | // GetDeltas returns the responder's current generation vector and all |
| 532 | // the missing log records when compared to the initiator's generation |
Himabindu Pucha | b41fc14 | 2015-09-10 17:10:57 -0700 | [diff] [blame] | 533 | // vector for one Database for either SyncGroup metadata or data. |
| 534 | GetDeltas(ctx *context.T, call *SyncGetDeltasServerCallStub, req DeltaReq, initiator string) error |
Raja Daoud | 5285136 | 2015-09-14 15:50:40 -0700 | [diff] [blame^] | 535 | // PublishSyncGroup is invoked on the SyncGroup name (typically served |
| 536 | // by a "central" peer) to publish the SyncGroup. It takes the name of |
| 537 | // Syncbase doing the publishing (the publisher) and returns the name |
| 538 | // of the Syncbase where the SyncGroup is published (the publishee). |
| 539 | // This allows the publisher and the publishee to learn of each other. |
| 540 | // When a SyncGroup is published, the publishee is given the SyncGroup |
| 541 | // metadata, its current version at the publisher, and the current |
| 542 | // SyncGroup generation vector. The generation vector serves as a |
| 543 | // checkpoint at the time of publishing. The publishing proceeds |
| 544 | // asynchronously, and the publishee learns the SyncGroup history |
| 545 | // through the routine p2p sync process and determines when it has |
| 546 | // caught up to the level of knowledge at the time of publishing using |
| 547 | // the checkpointed generation vector. Until that point, the publishee |
| 548 | // locally deems the SyncGroup to be in a pending state and does not |
| 549 | // mutate it. Thus it locally rejects SyncGroup joins or updates to |
| 550 | // its spec until it is caught up on the SyncGroup history. |
| 551 | PublishSyncGroup(ctx *context.T, call rpc.ServerCall, publisher string, sg SyncGroup, version string, genvec PrefixGenVector) (string, error) |
Himabindu Pucha | 03ef393 | 2015-06-26 17:56:09 -0700 | [diff] [blame] | 552 | // JoinSyncGroupAtAdmin is invoked by a prospective SyncGroup member's |
| 553 | // Syncbase on a SyncGroup admin. It checks whether the requestor is |
| 554 | // allowed to join the named SyncGroup, and if so, adds the requestor to |
Raja Daoud | 5285136 | 2015-09-14 15:50:40 -0700 | [diff] [blame^] | 555 | // the SyncGroup. It returns a copy of the updated SyncGroup metadata, |
| 556 | // its version, and the SyncGroup generation vector at the time of the |
| 557 | // join. Similar to the PublishSyncGroup scenario, the joiner at that |
| 558 | // point does not have the SyncGroup history and locally deems it to be |
| 559 | // in a pending state and does not mutate it. This means it rejects |
| 560 | // local updates to the SyncGroup spec or, if it were also an admin on |
| 561 | // the SyncGroup, it would reject SyncGroup joins until it is caught up |
| 562 | // on the SyncGroup history through p2p sync. |
| 563 | JoinSyncGroupAtAdmin(ctx *context.T, call rpc.ServerCall, sgName string, joinerName string, myInfo nosql.SyncGroupMemberInfo) (sg SyncGroup, version string, genvec PrefixGenVector, err error) |
Himabindu Pucha | 665f14c | 2015-08-13 13:42:01 -0700 | [diff] [blame] | 564 | // HaveBlob verifies that the peer has the requested blob, and if |
| 565 | // present, returns its size. |
| 566 | HaveBlob(ctx *context.T, call rpc.ServerCall, br nosql.BlobRef) (int64, error) |
| 567 | // FetchBlob fetches the requested blob. |
| 568 | FetchBlob(ctx *context.T, call *SyncFetchBlobServerCallStub, br nosql.BlobRef) error |
| 569 | // Methods for incremental blob transfer. The transfer starts with the |
| 570 | // receiver making a FetchBlobRecipe call to the sender for a given |
| 571 | // BlobRef. The sender, in turn, sends the chunk hashes of all the |
| 572 | // chunks that make up the requested blob (blob recipe). The receiver |
| 573 | // looks up the chunk hashes in its local blob store, and identifies the |
| 574 | // missing ones. The receiver then fetches the missing chunks using a |
| 575 | // FetchChunks call from the sender. Finally, the receiver finishes the |
| 576 | // blob fetch by combining the chunks obtained over the network with the |
| 577 | // already available local chunks as per the blob recipe. |
| 578 | FetchBlobRecipe(ctx *context.T, call *SyncFetchBlobRecipeServerCallStub, br nosql.BlobRef) error |
| 579 | FetchChunks(*context.T, *SyncFetchChunksServerCallStub) error |
Himabindu Pucha | 03ef393 | 2015-06-26 17:56:09 -0700 | [diff] [blame] | 580 | } |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 581 | |
| 582 | // SyncServerStub adds universal methods to SyncServerStubMethods. |
| 583 | type SyncServerStub interface { |
| 584 | SyncServerStubMethods |
| 585 | // Describe the Sync interfaces. |
| 586 | Describe__() []rpc.InterfaceDesc |
| 587 | } |
| 588 | |
| 589 | // SyncServer returns a server stub for Sync. |
| 590 | // It converts an implementation of SyncServerMethods into |
| 591 | // an object that may be used by rpc.Server. |
| 592 | func SyncServer(impl SyncServerMethods) SyncServerStub { |
| 593 | stub := implSyncServerStub{ |
| 594 | impl: impl, |
| 595 | } |
| 596 | // Initialize GlobState; always check the stub itself first, to handle the |
| 597 | // case where the user has the Glob method defined in their VDL source. |
| 598 | if gs := rpc.NewGlobState(stub); gs != nil { |
| 599 | stub.gs = gs |
| 600 | } else if gs := rpc.NewGlobState(impl); gs != nil { |
| 601 | stub.gs = gs |
| 602 | } |
| 603 | return stub |
| 604 | } |
| 605 | |
| 606 | type implSyncServerStub struct { |
| 607 | impl SyncServerMethods |
| 608 | gs *rpc.GlobState |
| 609 | } |
| 610 | |
Himabindu Pucha | b41fc14 | 2015-09-10 17:10:57 -0700 | [diff] [blame] | 611 | func (s implSyncServerStub) GetDeltas(ctx *context.T, call *SyncGetDeltasServerCallStub, i0 DeltaReq, i1 string) error { |
| 612 | return s.impl.GetDeltas(ctx, call, i0, i1) |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 613 | } |
| 614 | |
Raja Daoud | 5285136 | 2015-09-14 15:50:40 -0700 | [diff] [blame^] | 615 | func (s implSyncServerStub) PublishSyncGroup(ctx *context.T, call rpc.ServerCall, i0 string, i1 SyncGroup, i2 string, i3 PrefixGenVector) (string, error) { |
| 616 | return s.impl.PublishSyncGroup(ctx, call, i0, i1, i2, i3) |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 617 | } |
| 618 | |
Raja Daoud | 5285136 | 2015-09-14 15:50:40 -0700 | [diff] [blame^] | 619 | func (s implSyncServerStub) JoinSyncGroupAtAdmin(ctx *context.T, call rpc.ServerCall, i0 string, i1 string, i2 nosql.SyncGroupMemberInfo) (SyncGroup, string, PrefixGenVector, error) { |
Himabindu Pucha | 12e1a12 | 2015-06-08 15:59:09 -0700 | [diff] [blame] | 620 | return s.impl.JoinSyncGroupAtAdmin(ctx, call, i0, i1, i2) |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 621 | } |
| 622 | |
Himabindu Pucha | 665f14c | 2015-08-13 13:42:01 -0700 | [diff] [blame] | 623 | func (s implSyncServerStub) HaveBlob(ctx *context.T, call rpc.ServerCall, i0 nosql.BlobRef) (int64, error) { |
| 624 | return s.impl.HaveBlob(ctx, call, i0) |
| 625 | } |
| 626 | |
| 627 | func (s implSyncServerStub) FetchBlob(ctx *context.T, call *SyncFetchBlobServerCallStub, i0 nosql.BlobRef) error { |
Himabindu Pucha | 785502f | 2015-07-17 13:34:02 -0700 | [diff] [blame] | 628 | return s.impl.FetchBlob(ctx, call, i0) |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 629 | } |
| 630 | |
Himabindu Pucha | 665f14c | 2015-08-13 13:42:01 -0700 | [diff] [blame] | 631 | func (s implSyncServerStub) FetchBlobRecipe(ctx *context.T, call *SyncFetchBlobRecipeServerCallStub, i0 nosql.BlobRef) error { |
| 632 | return s.impl.FetchBlobRecipe(ctx, call, i0) |
| 633 | } |
| 634 | |
| 635 | func (s implSyncServerStub) FetchChunks(ctx *context.T, call *SyncFetchChunksServerCallStub) error { |
| 636 | return s.impl.FetchChunks(ctx, call) |
| 637 | } |
| 638 | |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 639 | func (s implSyncServerStub) Globber() *rpc.GlobState { |
| 640 | return s.gs |
| 641 | } |
| 642 | |
| 643 | func (s implSyncServerStub) Describe__() []rpc.InterfaceDesc { |
| 644 | return []rpc.InterfaceDesc{SyncDesc} |
| 645 | } |
| 646 | |
| 647 | // SyncDesc describes the Sync interface. |
| 648 | var SyncDesc rpc.InterfaceDesc = descSync |
| 649 | |
| 650 | // descSync hides the desc to keep godoc clean. |
| 651 | var descSync = rpc.InterfaceDesc{ |
| 652 | Name: "Sync", |
Adam Sadovsky | c908233 | 2015-08-31 13:58:38 -0700 | [diff] [blame] | 653 | PkgPath: "v.io/x/ref/services/syncbase/server/interfaces", |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 654 | Doc: "// Sync defines methods for data exchange between Syncbases.\n// TODO(hpucha): Flesh this out further.", |
| 655 | Methods: []rpc.MethodDesc{ |
| 656 | { |
| 657 | Name: "GetDeltas", |
Himabindu Pucha | b41fc14 | 2015-09-10 17:10:57 -0700 | [diff] [blame] | 658 | Doc: "// GetDeltas returns the responder's current generation vector and all\n// the missing log records when compared to the initiator's generation\n// vector for one Database for either SyncGroup metadata or data.", |
Raja Daoud | ccfd6c1 | 2015-08-03 18:46:28 -0700 | [diff] [blame] | 659 | InArgs: []rpc.ArgDesc{ |
Himabindu Pucha | b41fc14 | 2015-09-10 17:10:57 -0700 | [diff] [blame] | 660 | {"req", ``}, // DeltaReq |
Raja Daoud | ccfd6c1 | 2015-08-03 18:46:28 -0700 | [diff] [blame] | 661 | {"initiator", ``}, // string |
| 662 | }, |
Sergey Rogulenko | c2e60f6 | 2015-06-23 14:50:58 -0700 | [diff] [blame] | 663 | Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Read"))}, |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 664 | }, |
| 665 | { |
Himabindu Pucha | f9ec56f | 2015-06-02 11:34:05 -0700 | [diff] [blame] | 666 | Name: "PublishSyncGroup", |
Raja Daoud | 5285136 | 2015-09-14 15:50:40 -0700 | [diff] [blame^] | 667 | Doc: "// PublishSyncGroup is invoked on the SyncGroup name (typically served\n// by a \"central\" peer) to publish the SyncGroup. It takes the name of\n// Syncbase doing the publishing (the publisher) and returns the name\n// of the Syncbase where the SyncGroup is published (the publishee).\n// This allows the publisher and the publishee to learn of each other.\n// When a SyncGroup is published, the publishee is given the SyncGroup\n// metadata, its current version at the publisher, and the current\n// SyncGroup generation vector. The generation vector serves as a\n// checkpoint at the time of publishing. The publishing proceeds\n// asynchronously, and the publishee learns the SyncGroup history\n// through the routine p2p sync process and determines when it has\n// caught up to the level of knowledge at the time of publishing using\n// the checkpointed generation vector. Until that point, the publishee\n// locally deems the SyncGroup to be in a pending state and does not\n// mutate it. Thus it locally rejects SyncGroup joins or updates to\n// its spec until it is caught up on the SyncGroup history.", |
Himabindu Pucha | f9ec56f | 2015-06-02 11:34:05 -0700 | [diff] [blame] | 668 | InArgs: []rpc.ArgDesc{ |
Raja Daoud | 5285136 | 2015-09-14 15:50:40 -0700 | [diff] [blame^] | 669 | {"publisher", ``}, // string |
| 670 | {"sg", ``}, // SyncGroup |
| 671 | {"version", ``}, // string |
| 672 | {"genvec", ``}, // PrefixGenVector |
| 673 | }, |
| 674 | OutArgs: []rpc.ArgDesc{ |
| 675 | {"", ``}, // string |
Himabindu Pucha | f9ec56f | 2015-06-02 11:34:05 -0700 | [diff] [blame] | 676 | }, |
Sergey Rogulenko | c2e60f6 | 2015-06-23 14:50:58 -0700 | [diff] [blame] | 677 | Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Write"))}, |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 678 | }, |
| 679 | { |
Himabindu Pucha | 12e1a12 | 2015-06-08 15:59:09 -0700 | [diff] [blame] | 680 | Name: "JoinSyncGroupAtAdmin", |
Raja Daoud | 5285136 | 2015-09-14 15:50:40 -0700 | [diff] [blame^] | 681 | Doc: "// JoinSyncGroupAtAdmin is invoked by a prospective SyncGroup member's\n// Syncbase on a SyncGroup admin. It checks whether the requestor is\n// allowed to join the named SyncGroup, and if so, adds the requestor to\n// the SyncGroup. It returns a copy of the updated SyncGroup metadata,\n// its version, and the SyncGroup generation vector at the time of the\n// join. Similar to the PublishSyncGroup scenario, the joiner at that\n// point does not have the SyncGroup history and locally deems it to be\n// in a pending state and does not mutate it. This means it rejects\n// local updates to the SyncGroup spec or, if it were also an admin on\n// the SyncGroup, it would reject SyncGroup joins until it is caught up\n// on the SyncGroup history through p2p sync.", |
Himabindu Pucha | 12e1a12 | 2015-06-08 15:59:09 -0700 | [diff] [blame] | 682 | InArgs: []rpc.ArgDesc{ |
| 683 | {"sgName", ``}, // string |
| 684 | {"joinerName", ``}, // string |
| 685 | {"myInfo", ``}, // nosql.SyncGroupMemberInfo |
| 686 | }, |
| 687 | OutArgs: []rpc.ArgDesc{ |
Raja Daoud | 5285136 | 2015-09-14 15:50:40 -0700 | [diff] [blame^] | 688 | {"sg", ``}, // SyncGroup |
| 689 | {"version", ``}, // string |
| 690 | {"genvec", ``}, // PrefixGenVector |
Himabindu Pucha | 12e1a12 | 2015-06-08 15:59:09 -0700 | [diff] [blame] | 691 | }, |
Sergey Rogulenko | c2e60f6 | 2015-06-23 14:50:58 -0700 | [diff] [blame] | 692 | Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Read"))}, |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 693 | }, |
| 694 | { |
Himabindu Pucha | 665f14c | 2015-08-13 13:42:01 -0700 | [diff] [blame] | 695 | Name: "HaveBlob", |
| 696 | Doc: "// HaveBlob verifies that the peer has the requested blob, and if\n// present, returns its size.", |
Himabindu Pucha | 785502f | 2015-07-17 13:34:02 -0700 | [diff] [blame] | 697 | InArgs: []rpc.ArgDesc{ |
| 698 | {"br", ``}, // nosql.BlobRef |
| 699 | }, |
Himabindu Pucha | 665f14c | 2015-08-13 13:42:01 -0700 | [diff] [blame] | 700 | OutArgs: []rpc.ArgDesc{ |
| 701 | {"", ``}, // int64 |
| 702 | }, |
| 703 | }, |
| 704 | { |
| 705 | Name: "FetchBlob", |
| 706 | Doc: "// FetchBlob fetches the requested blob.", |
| 707 | InArgs: []rpc.ArgDesc{ |
| 708 | {"br", ``}, // nosql.BlobRef |
| 709 | }, |
| 710 | }, |
| 711 | { |
| 712 | Name: "FetchBlobRecipe", |
| 713 | Doc: "// Methods for incremental blob transfer. The transfer starts with the\n// receiver making a FetchBlobRecipe call to the sender for a given\n// BlobRef. The sender, in turn, sends the chunk hashes of all the\n// chunks that make up the requested blob (blob recipe). The receiver\n// looks up the chunk hashes in its local blob store, and identifies the\n// missing ones. The receiver then fetches the missing chunks using a\n// FetchChunks call from the sender. Finally, the receiver finishes the\n// blob fetch by combining the chunks obtained over the network with the\n// already available local chunks as per the blob recipe.", |
| 714 | InArgs: []rpc.ArgDesc{ |
| 715 | {"br", ``}, // nosql.BlobRef |
| 716 | }, |
| 717 | }, |
| 718 | { |
| 719 | Name: "FetchChunks", |
Himabindu Pucha | fb26a83 | 2015-05-20 15:37:50 -0700 | [diff] [blame] | 720 | }, |
| 721 | }, |
| 722 | } |
Himabindu Pucha | 03ef393 | 2015-06-26 17:56:09 -0700 | [diff] [blame] | 723 | |
| 724 | // SyncGetDeltasServerStream is the server stream for Sync.GetDeltas. |
| 725 | type SyncGetDeltasServerStream interface { |
Himabindu Pucha | 03ef393 | 2015-06-26 17:56:09 -0700 | [diff] [blame] | 726 | // SendStream returns the send side of the Sync.GetDeltas server stream. |
| 727 | SendStream() interface { |
| 728 | // Send places the item onto the output stream. Returns errors encountered |
| 729 | // while sending. Blocks if there is no buffer space; will unblock when |
| 730 | // buffer space is available. |
| 731 | Send(item DeltaResp) error |
| 732 | } |
| 733 | } |
| 734 | |
| 735 | // SyncGetDeltasServerCall represents the context passed to Sync.GetDeltas. |
| 736 | type SyncGetDeltasServerCall interface { |
| 737 | rpc.ServerCall |
| 738 | SyncGetDeltasServerStream |
| 739 | } |
| 740 | |
| 741 | // SyncGetDeltasServerCallStub is a wrapper that converts rpc.StreamServerCall into |
| 742 | // a typesafe stub that implements SyncGetDeltasServerCall. |
| 743 | type SyncGetDeltasServerCallStub struct { |
| 744 | rpc.StreamServerCall |
Himabindu Pucha | 03ef393 | 2015-06-26 17:56:09 -0700 | [diff] [blame] | 745 | } |
| 746 | |
| 747 | // Init initializes SyncGetDeltasServerCallStub from rpc.StreamServerCall. |
| 748 | func (s *SyncGetDeltasServerCallStub) Init(call rpc.StreamServerCall) { |
| 749 | s.StreamServerCall = call |
| 750 | } |
| 751 | |
Himabindu Pucha | 03ef393 | 2015-06-26 17:56:09 -0700 | [diff] [blame] | 752 | // SendStream returns the send side of the Sync.GetDeltas server stream. |
| 753 | func (s *SyncGetDeltasServerCallStub) SendStream() interface { |
| 754 | Send(item DeltaResp) error |
| 755 | } { |
| 756 | return implSyncGetDeltasServerCallSend{s} |
| 757 | } |
| 758 | |
| 759 | type implSyncGetDeltasServerCallSend struct { |
| 760 | s *SyncGetDeltasServerCallStub |
| 761 | } |
| 762 | |
| 763 | func (s implSyncGetDeltasServerCallSend) Send(item DeltaResp) error { |
| 764 | return s.s.Send(item) |
| 765 | } |
Himabindu Pucha | 665f14c | 2015-08-13 13:42:01 -0700 | [diff] [blame] | 766 | |
| 767 | // SyncFetchBlobServerStream is the server stream for Sync.FetchBlob. |
| 768 | type SyncFetchBlobServerStream interface { |
| 769 | // SendStream returns the send side of the Sync.FetchBlob server stream. |
| 770 | SendStream() interface { |
| 771 | // Send places the item onto the output stream. Returns errors encountered |
| 772 | // while sending. Blocks if there is no buffer space; will unblock when |
| 773 | // buffer space is available. |
| 774 | Send(item []byte) error |
| 775 | } |
| 776 | } |
| 777 | |
| 778 | // SyncFetchBlobServerCall represents the context passed to Sync.FetchBlob. |
| 779 | type SyncFetchBlobServerCall interface { |
| 780 | rpc.ServerCall |
| 781 | SyncFetchBlobServerStream |
| 782 | } |
| 783 | |
| 784 | // SyncFetchBlobServerCallStub is a wrapper that converts rpc.StreamServerCall into |
| 785 | // a typesafe stub that implements SyncFetchBlobServerCall. |
| 786 | type SyncFetchBlobServerCallStub struct { |
| 787 | rpc.StreamServerCall |
| 788 | } |
| 789 | |
| 790 | // Init initializes SyncFetchBlobServerCallStub from rpc.StreamServerCall. |
| 791 | func (s *SyncFetchBlobServerCallStub) Init(call rpc.StreamServerCall) { |
| 792 | s.StreamServerCall = call |
| 793 | } |
| 794 | |
| 795 | // SendStream returns the send side of the Sync.FetchBlob server stream. |
| 796 | func (s *SyncFetchBlobServerCallStub) SendStream() interface { |
| 797 | Send(item []byte) error |
| 798 | } { |
| 799 | return implSyncFetchBlobServerCallSend{s} |
| 800 | } |
| 801 | |
| 802 | type implSyncFetchBlobServerCallSend struct { |
| 803 | s *SyncFetchBlobServerCallStub |
| 804 | } |
| 805 | |
| 806 | func (s implSyncFetchBlobServerCallSend) Send(item []byte) error { |
| 807 | return s.s.Send(item) |
| 808 | } |
| 809 | |
| 810 | // SyncFetchBlobRecipeServerStream is the server stream for Sync.FetchBlobRecipe. |
| 811 | type SyncFetchBlobRecipeServerStream interface { |
| 812 | // SendStream returns the send side of the Sync.FetchBlobRecipe server stream. |
| 813 | SendStream() interface { |
| 814 | // Send places the item onto the output stream. Returns errors encountered |
| 815 | // while sending. Blocks if there is no buffer space; will unblock when |
| 816 | // buffer space is available. |
| 817 | Send(item ChunkHash) error |
| 818 | } |
| 819 | } |
| 820 | |
| 821 | // SyncFetchBlobRecipeServerCall represents the context passed to Sync.FetchBlobRecipe. |
| 822 | type SyncFetchBlobRecipeServerCall interface { |
| 823 | rpc.ServerCall |
| 824 | SyncFetchBlobRecipeServerStream |
| 825 | } |
| 826 | |
| 827 | // SyncFetchBlobRecipeServerCallStub is a wrapper that converts rpc.StreamServerCall into |
| 828 | // a typesafe stub that implements SyncFetchBlobRecipeServerCall. |
| 829 | type SyncFetchBlobRecipeServerCallStub struct { |
| 830 | rpc.StreamServerCall |
| 831 | } |
| 832 | |
| 833 | // Init initializes SyncFetchBlobRecipeServerCallStub from rpc.StreamServerCall. |
| 834 | func (s *SyncFetchBlobRecipeServerCallStub) Init(call rpc.StreamServerCall) { |
| 835 | s.StreamServerCall = call |
| 836 | } |
| 837 | |
| 838 | // SendStream returns the send side of the Sync.FetchBlobRecipe server stream. |
| 839 | func (s *SyncFetchBlobRecipeServerCallStub) SendStream() interface { |
| 840 | Send(item ChunkHash) error |
| 841 | } { |
| 842 | return implSyncFetchBlobRecipeServerCallSend{s} |
| 843 | } |
| 844 | |
| 845 | type implSyncFetchBlobRecipeServerCallSend struct { |
| 846 | s *SyncFetchBlobRecipeServerCallStub |
| 847 | } |
| 848 | |
| 849 | func (s implSyncFetchBlobRecipeServerCallSend) Send(item ChunkHash) error { |
| 850 | return s.s.Send(item) |
| 851 | } |
| 852 | |
| 853 | // SyncFetchChunksServerStream is the server stream for Sync.FetchChunks. |
| 854 | type SyncFetchChunksServerStream interface { |
| 855 | // RecvStream returns the receiver side of the Sync.FetchChunks server stream. |
| 856 | RecvStream() interface { |
| 857 | // Advance stages an item so that it may be retrieved via Value. Returns |
| 858 | // true iff there is an item to retrieve. Advance must be called before |
| 859 | // Value is called. May block if an item is not available. |
| 860 | Advance() bool |
| 861 | // Value returns the item that was staged by Advance. May panic if Advance |
| 862 | // returned false or was not called. Never blocks. |
| 863 | Value() ChunkHash |
| 864 | // Err returns any error encountered by Advance. Never blocks. |
| 865 | Err() error |
| 866 | } |
| 867 | // SendStream returns the send side of the Sync.FetchChunks server stream. |
| 868 | SendStream() interface { |
| 869 | // Send places the item onto the output stream. Returns errors encountered |
| 870 | // while sending. Blocks if there is no buffer space; will unblock when |
| 871 | // buffer space is available. |
| 872 | Send(item ChunkData) error |
| 873 | } |
| 874 | } |
| 875 | |
| 876 | // SyncFetchChunksServerCall represents the context passed to Sync.FetchChunks. |
| 877 | type SyncFetchChunksServerCall interface { |
| 878 | rpc.ServerCall |
| 879 | SyncFetchChunksServerStream |
| 880 | } |
| 881 | |
| 882 | // SyncFetchChunksServerCallStub is a wrapper that converts rpc.StreamServerCall into |
| 883 | // a typesafe stub that implements SyncFetchChunksServerCall. |
| 884 | type SyncFetchChunksServerCallStub struct { |
| 885 | rpc.StreamServerCall |
| 886 | valRecv ChunkHash |
| 887 | errRecv error |
| 888 | } |
| 889 | |
| 890 | // Init initializes SyncFetchChunksServerCallStub from rpc.StreamServerCall. |
| 891 | func (s *SyncFetchChunksServerCallStub) Init(call rpc.StreamServerCall) { |
| 892 | s.StreamServerCall = call |
| 893 | } |
| 894 | |
| 895 | // RecvStream returns the receiver side of the Sync.FetchChunks server stream. |
| 896 | func (s *SyncFetchChunksServerCallStub) RecvStream() interface { |
| 897 | Advance() bool |
| 898 | Value() ChunkHash |
| 899 | Err() error |
| 900 | } { |
| 901 | return implSyncFetchChunksServerCallRecv{s} |
| 902 | } |
| 903 | |
| 904 | type implSyncFetchChunksServerCallRecv struct { |
| 905 | s *SyncFetchChunksServerCallStub |
| 906 | } |
| 907 | |
| 908 | func (s implSyncFetchChunksServerCallRecv) Advance() bool { |
| 909 | s.s.valRecv = ChunkHash{} |
| 910 | s.s.errRecv = s.s.Recv(&s.s.valRecv) |
| 911 | return s.s.errRecv == nil |
| 912 | } |
| 913 | func (s implSyncFetchChunksServerCallRecv) Value() ChunkHash { |
| 914 | return s.s.valRecv |
| 915 | } |
| 916 | func (s implSyncFetchChunksServerCallRecv) Err() error { |
| 917 | if s.s.errRecv == io.EOF { |
| 918 | return nil |
| 919 | } |
| 920 | return s.s.errRecv |
| 921 | } |
| 922 | |
| 923 | // SendStream returns the send side of the Sync.FetchChunks server stream. |
| 924 | func (s *SyncFetchChunksServerCallStub) SendStream() interface { |
| 925 | Send(item ChunkData) error |
| 926 | } { |
| 927 | return implSyncFetchChunksServerCallSend{s} |
| 928 | } |
| 929 | |
| 930 | type implSyncFetchChunksServerCallSend struct { |
| 931 | s *SyncFetchChunksServerCallStub |
| 932 | } |
| 933 | |
| 934 | func (s implSyncFetchChunksServerCallSend) Send(item ChunkData) error { |
| 935 | return s.s.Send(item) |
| 936 | } |