blob: f81a4b722ce4010b9ab05c3717ead635a8d149e3 [file] [log] [blame]
Todd Wange5d67b42014-05-27 10:48:07 -07001// This file was auto-generated by the veyron vdl tool.
Tilak Sharma43395f32014-05-27 11:33:38 -07002// Source: vsync.vdl
Jiri Simsa5293dcb2014-05-10 09:56:38 -07003
4package vsync
5
6import (
Tilak Sharma2af70022014-05-14 11:29:27 -07007 "veyron/services/store/raw"
Jiri Simsa5293dcb2014-05-10 09:56:38 -07008
9 "veyron2/storage"
10
11 // The non-user imports are prefixed with "_gen_" to prevent collisions.
Cosmos Nicolaoub07fa772014-05-16 08:07:02 -070012 _gen_veyron2 "veyron2"
Matt Rosencrantz29147f72014-06-06 12:46:01 -070013 _gen_context "veyron2/context"
Jiri Simsa5293dcb2014-05-10 09:56:38 -070014 _gen_ipc "veyron2/ipc"
15 _gen_naming "veyron2/naming"
Cosmos Nicolaouae678942014-05-17 17:21:43 -070016 _gen_rt "veyron2/rt"
Todd Wang0ecdd7a2014-07-14 16:24:38 -070017 _gen_vdlutil "veyron2/vdl/vdlutil"
Jiri Simsa5293dcb2014-05-10 09:56:38 -070018 _gen_wiretype "veyron2/wiretype"
19)
20
21// DeviceID is the globally unique ID of a device.
22type DeviceID string
23
24// GenID is the unique ID per generation per device.
25type GenID uint64
26
27// LSN is the log sequence number.
28type LSN uint64
29
30// GenVector is the generation vector.
31type GenVector map[DeviceID]GenID
32
Jiri Simsa5293dcb2014-05-10 09:56:38 -070033// LogRec represents a single log record that is exchanged between two
34// peers.
35//
36// It contains log related metadata: DevID is the id of the
37// device that created the log record, GNum is the ID of the
Himabindu Puchad94c2e92014-06-12 13:47:53 -070038// generation that the log record is part of, LSN is the log
39// sequence number of the log record in the generation GNum,
40// and RecType is the type of log record.
Jiri Simsa5293dcb2014-05-10 09:56:38 -070041//
42// It also contains information relevant to the updates to an object
43// in the store: ObjID is the id of the object that was
44// updated. CurVers is the current version number of the
45// object. Parents can contain 0, 1 or 2 parent versions that the
46// current version is derived from, and Value is the actual value of
47// the object mutation.
48type LogRec struct {
49 // Log related information.
Himabindu Puchad94c2e92014-06-12 13:47:53 -070050 DevID DeviceID
51 GNum GenID
52 LSN LSN
53 RecType byte
Jiri Simsa5293dcb2014-05-10 09:56:38 -070054 // Object related information.
55 ObjID storage.ID
56 CurVers storage.Version
57 Parents []storage.Version
58 Value LogValue
59}
60
Todd Wange5d67b42014-05-27 10:48:07 -070061// LogValue represents an object mutation within a transaction.
62type LogValue struct {
63 // Mutation is the store mutation representing the change in the object.
64 Mutation raw.Mutation
65 // SyncTime is the timestamp of the mutation when it arrives at the Sync server.
66 SyncTime int64
67 // Delete indicates whether the mutation resulted in the object being
68 // deleted from the store.
69 Delete bool
Benjamin Prosnitz59162a02014-07-02 10:07:14 -070070 // Continued tracks the transaction boundaries in a range of mutations.
Todd Wange5d67b42014-05-27 10:48:07 -070071 // It is set to true in all transaction mutations except the last one
72 // in which it is set to false to mark the end of the transaction.
Benjamin Prosnitz59162a02014-07-02 10:07:14 -070073 Continued bool
Todd Wange5d67b42014-05-27 10:48:07 -070074}
75
Himabindu Puchad94c2e92014-06-12 13:47:53 -070076const (
77 // NodeRec type log record adds a new node in the dag.
78 NodeRec = byte(0)
79
80 // LinkRec type log record adds a new link in the dag.
81 LinkRec = byte(1)
82)
83
Jiri Simsa5293dcb2014-05-10 09:56:38 -070084// Sync allows a device to GetDeltas from another device.
85// Sync is the interface the client binds and uses.
Benjamin Prosnitzdcddb932014-05-27 15:55:58 -070086// Sync_ExcludingUniversal is the interface without internal framework-added methods
87// to enable embedding without method collisions. Not to be used directly by clients.
88type Sync_ExcludingUniversal interface {
Jiri Simsa5293dcb2014-05-10 09:56:38 -070089 // GetDeltas returns a device's current generation vector and all the missing log records
90 // when compared to the incoming generation vector.
Jiri Simsa3ac5fc52014-06-30 19:49:09 +000091 GetDeltas(ctx _gen_context.T, In GenVector, ClientID DeviceID, opts ..._gen_ipc.CallOpt) (reply SyncGetDeltasStream, err error)
Jiri Simsa5293dcb2014-05-10 09:56:38 -070092}
93type Sync interface {
Benjamin Prosnitzdcddb932014-05-27 15:55:58 -070094 _gen_ipc.UniversalServiceMethods
95 Sync_ExcludingUniversal
Jiri Simsa5293dcb2014-05-10 09:56:38 -070096}
97
98// SyncService is the interface the server implements.
99type SyncService interface {
100
101 // GetDeltas returns a device's current generation vector and all the missing log records
102 // when compared to the incoming generation vector.
Jiri Simsa3ac5fc52014-06-30 19:49:09 +0000103 GetDeltas(context _gen_ipc.ServerContext, In GenVector, ClientID DeviceID, stream SyncServiceGetDeltasStream) (reply GenVector, err error)
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700104}
105
106// SyncGetDeltasStream is the interface for streaming responses of the method
107// GetDeltas in the service interface Sync.
108type SyncGetDeltasStream interface {
109
110 // Recv returns the next item in the input stream, blocking until
Benjamin Prosnitzce3898a2014-07-22 13:17:22 -0700111 // an item is available. Returns io.EOF to indicate graceful end of input.
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700112 Recv() (item LogRec, err error)
113
Benjamin Prosnitzce3898a2014-07-22 13:17:22 -0700114 // Finish closes the stream and returns the positional return values for
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700115 // call.
116 Finish() (reply GenVector, err error)
117
Benjamin Prosnitzce3898a2014-07-22 13:17:22 -0700118 // Cancel cancels the RPC, notifying the server to stop processing.
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700119 Cancel()
120}
121
122// Implementation of the SyncGetDeltasStream interface that is not exported.
123type implSyncGetDeltasStream struct {
Matt Rosencrantzf5afcaf2014-06-02 11:31:22 -0700124 clientCall _gen_ipc.Call
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700125}
126
127func (c *implSyncGetDeltasStream) Recv() (item LogRec, err error) {
128 err = c.clientCall.Recv(&item)
129 return
130}
131
132func (c *implSyncGetDeltasStream) Finish() (reply GenVector, err error) {
133 if ierr := c.clientCall.Finish(&reply, &err); ierr != nil {
134 err = ierr
135 }
136 return
137}
138
139func (c *implSyncGetDeltasStream) Cancel() {
140 c.clientCall.Cancel()
141}
142
143// SyncServiceGetDeltasStream is the interface for streaming responses of the method
144// GetDeltas in the service interface Sync.
145type SyncServiceGetDeltasStream interface {
146 // Send places the item onto the output stream, blocking if there is no buffer
Benjamin Prosnitzce3898a2014-07-22 13:17:22 -0700147 // space available.
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700148 Send(item LogRec) error
149}
150
151// Implementation of the SyncServiceGetDeltasStream interface that is not exported.
152type implSyncServiceGetDeltasStream struct {
153 serverCall _gen_ipc.ServerCall
154}
155
156func (s *implSyncServiceGetDeltasStream) Send(item LogRec) error {
157 return s.serverCall.Send(item)
158}
159
160// BindSync returns the client stub implementing the Sync
161// interface.
162//
163// If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the
164// global Runtime is used.
165func BindSync(name string, opts ..._gen_ipc.BindOpt) (Sync, error) {
166 var client _gen_ipc.Client
167 switch len(opts) {
168 case 0:
169 client = _gen_rt.R().Client()
170 case 1:
171 switch o := opts[0].(type) {
Cosmos Nicolaoub07fa772014-05-16 08:07:02 -0700172 case _gen_veyron2.Runtime:
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700173 client = o.Client()
174 case _gen_ipc.Client:
175 client = o
176 default:
Todd Wang0ecdd7a2014-07-14 16:24:38 -0700177 return nil, _gen_vdlutil.ErrUnrecognizedOption
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700178 }
179 default:
Todd Wang0ecdd7a2014-07-14 16:24:38 -0700180 return nil, _gen_vdlutil.ErrTooManyOptionsToBind
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700181 }
182 stub := &clientStubSync{client: client, name: name}
183
184 return stub, nil
185}
186
187// NewServerSync creates a new server stub.
188//
189// It takes a regular server implementing the SyncService
190// interface, and returns a new server stub.
191func NewServerSync(server SyncService) interface{} {
192 return &ServerStubSync{
193 service: server,
194 }
195}
196
197// clientStubSync implements Sync.
198type clientStubSync struct {
199 client _gen_ipc.Client
200 name string
201}
202
Jiri Simsa3ac5fc52014-06-30 19:49:09 +0000203func (__gen_c *clientStubSync) GetDeltas(ctx _gen_context.T, In GenVector, ClientID DeviceID, opts ..._gen_ipc.CallOpt) (reply SyncGetDeltasStream, err error) {
Matt Rosencrantzf5afcaf2014-06-02 11:31:22 -0700204 var call _gen_ipc.Call
Jiri Simsa3ac5fc52014-06-30 19:49:09 +0000205 if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "GetDeltas", []interface{}{In, ClientID}, opts...); err != nil {
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700206 return
207 }
208 reply = &implSyncGetDeltasStream{clientCall: call}
209 return
210}
211
Matt Rosencrantz29147f72014-06-06 12:46:01 -0700212func (__gen_c *clientStubSync) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) {
Matt Rosencrantzf5afcaf2014-06-02 11:31:22 -0700213 var call _gen_ipc.Call
214 if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil {
Benjamin Prosnitzdcddb932014-05-27 15:55:58 -0700215 return
216 }
217 if ierr := call.Finish(&reply, &err); ierr != nil {
218 err = ierr
219 }
220 return
221}
222
Matt Rosencrantz29147f72014-06-06 12:46:01 -0700223func (__gen_c *clientStubSync) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) {
Matt Rosencrantzf5afcaf2014-06-02 11:31:22 -0700224 var call _gen_ipc.Call
225 if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil {
Benjamin Prosnitzdcddb932014-05-27 15:55:58 -0700226 return
227 }
228 if ierr := call.Finish(&reply, &err); ierr != nil {
229 err = ierr
230 }
231 return
232}
233
Matt Rosencrantz29147f72014-06-06 12:46:01 -0700234func (__gen_c *clientStubSync) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) {
Matt Rosencrantzf5afcaf2014-06-02 11:31:22 -0700235 var call _gen_ipc.Call
236 if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700237 return
238 }
239 if ierr := call.Finish(&reply, &err); ierr != nil {
240 err = ierr
241 }
242 return
243}
244
245// ServerStubSync wraps a server that implements
246// SyncService and provides an object that satisfies
247// the requirements of veyron2/ipc.ReflectInvoker.
248type ServerStubSync struct {
249 service SyncService
250}
251
Benjamin Prosnitzdcddb932014-05-27 15:55:58 -0700252func (__gen_s *ServerStubSync) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) {
253 // TODO(bprosnitz) GetMethodTags() will be replaces with Signature().
254 // Note: This exhibits some weird behavior like returning a nil error if the method isn't found.
255 // This will change when it is replaced with Signature().
256 switch method {
257 case "GetDeltas":
258 return []interface{}{}, nil
259 default:
260 return nil, nil
261 }
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700262}
263
Benjamin Prosnitzdcddb932014-05-27 15:55:58 -0700264func (__gen_s *ServerStubSync) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) {
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700265 result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)}
266 result.Methods["GetDeltas"] = _gen_ipc.MethodSignature{
267 InArgs: []_gen_ipc.MethodArgument{
Jiri Simsa3ac5fc52014-06-30 19:49:09 +0000268 {Name: "In", Type: 67},
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700269 {Name: "ClientID", Type: 65},
270 },
271 OutArgs: []_gen_ipc.MethodArgument{
Jiri Simsa3ac5fc52014-06-30 19:49:09 +0000272 {Name: "Out", Type: 67},
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700273 {Name: "Err", Type: 68},
274 },
275
Todd Wange5d67b42014-05-27 10:48:07 -0700276 OutStream: 82,
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700277 }
278
Todd Wang0ecdd7a2014-07-14 16:24:38 -0700279 result.TypeDefs = []_gen_vdlutil.Any{
Todd Wange5d67b42014-05-27 10:48:07 -0700280 _gen_wiretype.NamedPrimitiveType{Type: 0x3, Name: "veyron/runtimes/google/vsync.DeviceID", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x35, Name: "veyron/runtimes/google/vsync.GenID", Tags: []string(nil)}, _gen_wiretype.MapType{Key: 0x41, Elem: 0x42, Name: "veyron/runtimes/google/vsync.GenVector", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x35, Name: "veyron/runtimes/google/vsync.LSN", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, _gen_wiretype.ArrayType{Elem: 0x46, Len: 0x10, Name: "veyron2/storage.ID", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x35, Name: "veyron2/storage.Version", Tags: []string(nil)}, _gen_wiretype.SliceType{Elem: 0x48, Name: "", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "anydata", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x32, Name: "veyron2/storage.TagOp", Tags: []string(nil)}, _gen_wiretype.StructType{
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700281 []_gen_wiretype.FieldType{
282 _gen_wiretype.FieldType{Type: 0x4b, Name: "Op"},
Todd Wange5d67b42014-05-27 10:48:07 -0700283 _gen_wiretype.FieldType{Type: 0x47, Name: "ACL"},
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700284 },
Todd Wange5d67b42014-05-27 10:48:07 -0700285 "veyron2/storage.Tag", []string(nil)},
286 _gen_wiretype.SliceType{Elem: 0x4c, Name: "veyron2/storage.TagList", Tags: []string(nil)}, _gen_wiretype.StructType{
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700287 []_gen_wiretype.FieldType{
288 _gen_wiretype.FieldType{Type: 0x3, Name: "Name"},
Todd Wange5d67b42014-05-27 10:48:07 -0700289 _gen_wiretype.FieldType{Type: 0x47, Name: "ID"},
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700290 },
Todd Wange5d67b42014-05-27 10:48:07 -0700291 "veyron2/storage.DEntry", []string(nil)},
292 _gen_wiretype.SliceType{Elem: 0x4e, Name: "", Tags: []string(nil)}, _gen_wiretype.StructType{
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700293 []_gen_wiretype.FieldType{
294 _gen_wiretype.FieldType{Type: 0x47, Name: "ID"},
295 _gen_wiretype.FieldType{Type: 0x48, Name: "PriorVersion"},
296 _gen_wiretype.FieldType{Type: 0x48, Name: "Version"},
297 _gen_wiretype.FieldType{Type: 0x2, Name: "IsRoot"},
298 _gen_wiretype.FieldType{Type: 0x4a, Name: "Value"},
Todd Wange5d67b42014-05-27 10:48:07 -0700299 _gen_wiretype.FieldType{Type: 0x4d, Name: "Tags"},
300 _gen_wiretype.FieldType{Type: 0x4f, Name: "Dir"},
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700301 },
Todd Wange5d67b42014-05-27 10:48:07 -0700302 "veyron/services/store/raw.Mutation", []string(nil)},
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700303 _gen_wiretype.StructType{
304 []_gen_wiretype.FieldType{
Todd Wange5d67b42014-05-27 10:48:07 -0700305 _gen_wiretype.FieldType{Type: 0x50, Name: "Mutation"},
Raja Daoudc861ab42014-05-20 14:32:54 -0700306 _gen_wiretype.FieldType{Type: 0x25, Name: "SyncTime"},
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700307 _gen_wiretype.FieldType{Type: 0x2, Name: "Delete"},
Benjamin Prosnitz59162a02014-07-02 10:07:14 -0700308 _gen_wiretype.FieldType{Type: 0x2, Name: "Continued"},
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700309 },
Todd Wange5d67b42014-05-27 10:48:07 -0700310 "veyron/runtimes/google/vsync.LogValue", []string(nil)},
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700311 _gen_wiretype.StructType{
312 []_gen_wiretype.FieldType{
313 _gen_wiretype.FieldType{Type: 0x41, Name: "DevID"},
314 _gen_wiretype.FieldType{Type: 0x42, Name: "GNum"},
315 _gen_wiretype.FieldType{Type: 0x45, Name: "LSN"},
Himabindu Puchad94c2e92014-06-12 13:47:53 -0700316 _gen_wiretype.FieldType{Type: 0x46, Name: "RecType"},
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700317 _gen_wiretype.FieldType{Type: 0x47, Name: "ObjID"},
318 _gen_wiretype.FieldType{Type: 0x48, Name: "CurVers"},
319 _gen_wiretype.FieldType{Type: 0x49, Name: "Parents"},
Todd Wange5d67b42014-05-27 10:48:07 -0700320 _gen_wiretype.FieldType{Type: 0x51, Name: "Value"},
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700321 },
Todd Wange5d67b42014-05-27 10:48:07 -0700322 "veyron/runtimes/google/vsync.LogRec", []string(nil)},
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700323 }
324
325 return result, nil
326}
327
Benjamin Prosnitzdcddb932014-05-27 15:55:58 -0700328func (__gen_s *ServerStubSync) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) {
329 if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok {
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700330 return unresolver.UnresolveStep(call)
331 }
332 if call.Server() == nil {
333 return
334 }
335 var published []string
336 if published, err = call.Server().Published(); err != nil || published == nil {
337 return
338 }
339 reply = make([]string, len(published))
340 for i, p := range published {
341 reply[i] = _gen_naming.Join(p, call.Name())
342 }
343 return
344}
345
Jiri Simsa3ac5fc52014-06-30 19:49:09 +0000346func (__gen_s *ServerStubSync) GetDeltas(call _gen_ipc.ServerCall, In GenVector, ClientID DeviceID) (reply GenVector, err error) {
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700347 stream := &implSyncServiceGetDeltasStream{serverCall: call}
Jiri Simsa3ac5fc52014-06-30 19:49:09 +0000348 reply, err = __gen_s.service.GetDeltas(call, In, ClientID, stream)
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700349 return
350}