blob: 20557347390fe34c55314cdb298b6f12eba871ba [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 Wange5d67b42014-05-27 10:48:07 -070017 _gen_vdl "veyron2/vdl"
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
38// generation that the log record is part of, and LSN is the log
39// sequence number of the log record in the generation GNum.
40//
41// It also contains information relevant to the updates to an object
42// in the store: ObjID is the id of the object that was
43// updated. CurVers is the current version number of the
44// object. Parents can contain 0, 1 or 2 parent versions that the
45// current version is derived from, and Value is the actual value of
46// the object mutation.
47type LogRec struct {
48 // Log related information.
49 DevID DeviceID
50 GNum GenID
51 LSN LSN
52 // Object related information.
53 ObjID storage.ID
54 CurVers storage.Version
55 Parents []storage.Version
56 Value LogValue
57}
58
Todd Wange5d67b42014-05-27 10:48:07 -070059// LogValue represents an object mutation within a transaction.
60type LogValue struct {
61 // Mutation is the store mutation representing the change in the object.
62 Mutation raw.Mutation
63 // SyncTime is the timestamp of the mutation when it arrives at the Sync server.
64 SyncTime int64
65 // Delete indicates whether the mutation resulted in the object being
66 // deleted from the store.
67 Delete bool
68 // Continue tracks the transaction boundaries in a range of mutations.
69 // It is set to true in all transaction mutations except the last one
70 // in which it is set to false to mark the end of the transaction.
71 Continue bool
72}
73
Jiri Simsa5293dcb2014-05-10 09:56:38 -070074// Sync allows a device to GetDeltas from another device.
75// Sync is the interface the client binds and uses.
Benjamin Prosnitzdcddb932014-05-27 15:55:58 -070076// Sync_ExcludingUniversal is the interface without internal framework-added methods
77// to enable embedding without method collisions. Not to be used directly by clients.
78type Sync_ExcludingUniversal interface {
Jiri Simsa5293dcb2014-05-10 09:56:38 -070079 // GetDeltas returns a device's current generation vector and all the missing log records
80 // when compared to the incoming generation vector.
Matt Rosencrantz29147f72014-06-06 12:46:01 -070081 GetDeltas(ctx _gen_context.T, In GenVector, ClientID DeviceID, opts ..._gen_ipc.CallOpt) (reply SyncGetDeltasStream, err error)
Jiri Simsa5293dcb2014-05-10 09:56:38 -070082}
83type Sync interface {
Benjamin Prosnitzdcddb932014-05-27 15:55:58 -070084 _gen_ipc.UniversalServiceMethods
85 Sync_ExcludingUniversal
Jiri Simsa5293dcb2014-05-10 09:56:38 -070086}
87
88// SyncService is the interface the server implements.
89type SyncService interface {
90
91 // GetDeltas returns a device's current generation vector and all the missing log records
92 // when compared to the incoming generation vector.
Matt Rosencrantzf5afcaf2014-06-02 11:31:22 -070093 GetDeltas(context _gen_ipc.ServerContext, In GenVector, ClientID DeviceID, stream SyncServiceGetDeltasStream) (reply GenVector, err error)
Jiri Simsa5293dcb2014-05-10 09:56:38 -070094}
95
96// SyncGetDeltasStream is the interface for streaming responses of the method
97// GetDeltas in the service interface Sync.
98type SyncGetDeltasStream interface {
99
100 // Recv returns the next item in the input stream, blocking until
101 // an item is available. Returns io.EOF to indicate graceful end of input.
102 Recv() (item LogRec, err error)
103
104 // Finish closes the stream and returns the positional return values for
105 // call.
106 Finish() (reply GenVector, err error)
107
108 // Cancel cancels the RPC, notifying the server to stop processing.
109 Cancel()
110}
111
112// Implementation of the SyncGetDeltasStream interface that is not exported.
113type implSyncGetDeltasStream struct {
Matt Rosencrantzf5afcaf2014-06-02 11:31:22 -0700114 clientCall _gen_ipc.Call
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700115}
116
117func (c *implSyncGetDeltasStream) Recv() (item LogRec, err error) {
118 err = c.clientCall.Recv(&item)
119 return
120}
121
122func (c *implSyncGetDeltasStream) Finish() (reply GenVector, err error) {
123 if ierr := c.clientCall.Finish(&reply, &err); ierr != nil {
124 err = ierr
125 }
126 return
127}
128
129func (c *implSyncGetDeltasStream) Cancel() {
130 c.clientCall.Cancel()
131}
132
133// SyncServiceGetDeltasStream is the interface for streaming responses of the method
134// GetDeltas in the service interface Sync.
135type SyncServiceGetDeltasStream interface {
136 // Send places the item onto the output stream, blocking if there is no buffer
137 // space available.
138 Send(item LogRec) error
139}
140
141// Implementation of the SyncServiceGetDeltasStream interface that is not exported.
142type implSyncServiceGetDeltasStream struct {
143 serverCall _gen_ipc.ServerCall
144}
145
146func (s *implSyncServiceGetDeltasStream) Send(item LogRec) error {
147 return s.serverCall.Send(item)
148}
149
150// BindSync returns the client stub implementing the Sync
151// interface.
152//
153// If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the
154// global Runtime is used.
155func BindSync(name string, opts ..._gen_ipc.BindOpt) (Sync, error) {
156 var client _gen_ipc.Client
157 switch len(opts) {
158 case 0:
159 client = _gen_rt.R().Client()
160 case 1:
161 switch o := opts[0].(type) {
Cosmos Nicolaoub07fa772014-05-16 08:07:02 -0700162 case _gen_veyron2.Runtime:
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700163 client = o.Client()
164 case _gen_ipc.Client:
165 client = o
166 default:
Todd Wange5d67b42014-05-27 10:48:07 -0700167 return nil, _gen_vdl.ErrUnrecognizedOption
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700168 }
169 default:
Todd Wange5d67b42014-05-27 10:48:07 -0700170 return nil, _gen_vdl.ErrTooManyOptionsToBind
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700171 }
172 stub := &clientStubSync{client: client, name: name}
173
174 return stub, nil
175}
176
177// NewServerSync creates a new server stub.
178//
179// It takes a regular server implementing the SyncService
180// interface, and returns a new server stub.
181func NewServerSync(server SyncService) interface{} {
182 return &ServerStubSync{
183 service: server,
184 }
185}
186
187// clientStubSync implements Sync.
188type clientStubSync struct {
189 client _gen_ipc.Client
190 name string
191}
192
Matt Rosencrantz29147f72014-06-06 12:46:01 -0700193func (__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 -0700194 var call _gen_ipc.Call
195 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 -0700196 return
197 }
198 reply = &implSyncGetDeltasStream{clientCall: call}
199 return
200}
201
Matt Rosencrantz29147f72014-06-06 12:46:01 -0700202func (__gen_c *clientStubSync) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) {
Matt Rosencrantzf5afcaf2014-06-02 11:31:22 -0700203 var call _gen_ipc.Call
204 if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil {
Benjamin Prosnitzdcddb932014-05-27 15:55:58 -0700205 return
206 }
207 if ierr := call.Finish(&reply, &err); ierr != nil {
208 err = ierr
209 }
210 return
211}
212
Matt Rosencrantz29147f72014-06-06 12:46:01 -0700213func (__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 -0700214 var call _gen_ipc.Call
215 if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil {
Benjamin Prosnitzdcddb932014-05-27 15:55:58 -0700216 return
217 }
218 if ierr := call.Finish(&reply, &err); ierr != nil {
219 err = ierr
220 }
221 return
222}
223
Matt Rosencrantz29147f72014-06-06 12:46:01 -0700224func (__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 -0700225 var call _gen_ipc.Call
226 if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700227 return
228 }
229 if ierr := call.Finish(&reply, &err); ierr != nil {
230 err = ierr
231 }
232 return
233}
234
235// ServerStubSync wraps a server that implements
236// SyncService and provides an object that satisfies
237// the requirements of veyron2/ipc.ReflectInvoker.
238type ServerStubSync struct {
239 service SyncService
240}
241
Benjamin Prosnitzdcddb932014-05-27 15:55:58 -0700242func (__gen_s *ServerStubSync) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) {
243 // TODO(bprosnitz) GetMethodTags() will be replaces with Signature().
244 // Note: This exhibits some weird behavior like returning a nil error if the method isn't found.
245 // This will change when it is replaced with Signature().
246 switch method {
247 case "GetDeltas":
248 return []interface{}{}, nil
249 default:
250 return nil, nil
251 }
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700252}
253
Benjamin Prosnitzdcddb932014-05-27 15:55:58 -0700254func (__gen_s *ServerStubSync) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) {
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700255 result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)}
256 result.Methods["GetDeltas"] = _gen_ipc.MethodSignature{
257 InArgs: []_gen_ipc.MethodArgument{
258 {Name: "In", Type: 67},
259 {Name: "ClientID", Type: 65},
260 },
261 OutArgs: []_gen_ipc.MethodArgument{
262 {Name: "Out", Type: 67},
263 {Name: "Err", Type: 68},
264 },
265
Todd Wange5d67b42014-05-27 10:48:07 -0700266 OutStream: 82,
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700267 }
268
Todd Wange5d67b42014-05-27 10:48:07 -0700269 result.TypeDefs = []_gen_vdl.Any{
270 _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 -0700271 []_gen_wiretype.FieldType{
272 _gen_wiretype.FieldType{Type: 0x4b, Name: "Op"},
Todd Wange5d67b42014-05-27 10:48:07 -0700273 _gen_wiretype.FieldType{Type: 0x47, Name: "ACL"},
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700274 },
Todd Wange5d67b42014-05-27 10:48:07 -0700275 "veyron2/storage.Tag", []string(nil)},
276 _gen_wiretype.SliceType{Elem: 0x4c, Name: "veyron2/storage.TagList", Tags: []string(nil)}, _gen_wiretype.StructType{
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700277 []_gen_wiretype.FieldType{
278 _gen_wiretype.FieldType{Type: 0x3, Name: "Name"},
Todd Wange5d67b42014-05-27 10:48:07 -0700279 _gen_wiretype.FieldType{Type: 0x47, Name: "ID"},
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700280 },
Todd Wange5d67b42014-05-27 10:48:07 -0700281 "veyron2/storage.DEntry", []string(nil)},
282 _gen_wiretype.SliceType{Elem: 0x4e, Name: "", Tags: []string(nil)}, _gen_wiretype.StructType{
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700283 []_gen_wiretype.FieldType{
284 _gen_wiretype.FieldType{Type: 0x47, Name: "ID"},
285 _gen_wiretype.FieldType{Type: 0x48, Name: "PriorVersion"},
286 _gen_wiretype.FieldType{Type: 0x48, Name: "Version"},
287 _gen_wiretype.FieldType{Type: 0x2, Name: "IsRoot"},
288 _gen_wiretype.FieldType{Type: 0x4a, Name: "Value"},
Todd Wange5d67b42014-05-27 10:48:07 -0700289 _gen_wiretype.FieldType{Type: 0x4d, Name: "Tags"},
290 _gen_wiretype.FieldType{Type: 0x4f, Name: "Dir"},
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700291 },
Todd Wange5d67b42014-05-27 10:48:07 -0700292 "veyron/services/store/raw.Mutation", []string(nil)},
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700293 _gen_wiretype.StructType{
294 []_gen_wiretype.FieldType{
Todd Wange5d67b42014-05-27 10:48:07 -0700295 _gen_wiretype.FieldType{Type: 0x50, Name: "Mutation"},
Raja Daoudc861ab42014-05-20 14:32:54 -0700296 _gen_wiretype.FieldType{Type: 0x25, Name: "SyncTime"},
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700297 _gen_wiretype.FieldType{Type: 0x2, Name: "Delete"},
298 _gen_wiretype.FieldType{Type: 0x2, Name: "Continue"},
299 },
Todd Wange5d67b42014-05-27 10:48:07 -0700300 "veyron/runtimes/google/vsync.LogValue", []string(nil)},
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700301 _gen_wiretype.StructType{
302 []_gen_wiretype.FieldType{
303 _gen_wiretype.FieldType{Type: 0x41, Name: "DevID"},
304 _gen_wiretype.FieldType{Type: 0x42, Name: "GNum"},
305 _gen_wiretype.FieldType{Type: 0x45, Name: "LSN"},
306 _gen_wiretype.FieldType{Type: 0x47, Name: "ObjID"},
307 _gen_wiretype.FieldType{Type: 0x48, Name: "CurVers"},
308 _gen_wiretype.FieldType{Type: 0x49, Name: "Parents"},
Todd Wange5d67b42014-05-27 10:48:07 -0700309 _gen_wiretype.FieldType{Type: 0x51, Name: "Value"},
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700310 },
Todd Wange5d67b42014-05-27 10:48:07 -0700311 "veyron/runtimes/google/vsync.LogRec", []string(nil)},
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700312 }
313
314 return result, nil
315}
316
Benjamin Prosnitzdcddb932014-05-27 15:55:58 -0700317func (__gen_s *ServerStubSync) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) {
318 if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok {
Jiri Simsa5293dcb2014-05-10 09:56:38 -0700319 return unresolver.UnresolveStep(call)
320 }
321 if call.Server() == nil {
322 return
323 }
324 var published []string
325 if published, err = call.Server().Published(); err != nil || published == nil {
326 return
327 }
328 reply = make([]string, len(published))
329 for i, p := range published {
330 reply[i] = _gen_naming.Join(p, call.Name())
331 }
332 return
333}
334
335func (__gen_s *ServerStubSync) GetDeltas(call _gen_ipc.ServerCall, In GenVector, ClientID DeviceID) (reply GenVector, err error) {
336 stream := &implSyncServiceGetDeltasStream{serverCall: call}
337 reply, err = __gen_s.service.GetDeltas(call, In, ClientID, stream)
338 return
339}