| // Copyright 2015 The Vanadium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| |
| // This file was auto-generated by the vanadium vdl tool. |
| // Source: sync_types.vdl |
| |
| package interfaces |
| |
| import ( |
| // VDL system imports |
| "fmt" |
| "v.io/v23/vdl" |
| |
| // VDL user imports |
| "time" |
| "v.io/v23/services/syncbase/nosql" |
| _ "v.io/v23/vdlroot/time" |
| ) |
| |
| // PrefixGenVector is the generation vector for a data prefix, which maps each |
| // device id to its last locally known generation in the scope of that prefix. |
| // TODO(hpucha): Rename this type. |
| type PrefixGenVector map[uint64]uint64 |
| |
| func (PrefixGenVector) __VDLReflect(struct { |
| Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.PrefixGenVector"` |
| }) { |
| } |
| |
| // GenVector is the generation vector for a Database, and maps prefixes to their |
| // generation vectors. Note that the prefixes in a GenVector are relative to the |
| // the Application and Database name. |
| type GenVector map[string]PrefixGenVector |
| |
| func (GenVector) __VDLReflect(struct { |
| Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.GenVector"` |
| }) { |
| } |
| |
| // LogRecMetadata represents the metadata of a single log record that is |
| // exchanged between two peers. Each log record represents a change made to an |
| // object in the store. |
| // |
| // TODO(hpucha): Add readset/scanset. Look into sending tx metadata only once |
| // per transaction. |
| type LogRecMetadata struct { |
| // Log related information. |
| Id uint64 // device id that created the log record. |
| Gen uint64 // generation number for the log record. |
| RecType byte // type of log record. |
| // Id of the object that was updated. This id is relative to Application |
| // and Database names and is the store key for a particular row in a |
| // table. |
| ObjId string |
| CurVers string // current version number of the object. |
| Parents []string // 0, 1 or 2 parent versions that the current version is derived from. |
| UpdTime time.Time // timestamp when the update is generated. |
| PermId string // id of the permissions object controlling this version. |
| PermVers string // current version of the permissions object. |
| Shell bool // true when the mutation data is hidden due to permissions. |
| Delete bool // indicates whether the update resulted in object being deleted from the store. |
| BatchId uint64 // unique id of the Batch this update belongs to. |
| BatchCount uint64 // number of objects in the Batch. |
| } |
| |
| func (LogRecMetadata) __VDLReflect(struct { |
| Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.LogRecMetadata"` |
| }) { |
| } |
| |
| // LogRec represents the on-wire representation of an entire log record: its |
| // metadata and data. Value is the actual value of a store object. |
| type LogRec struct { |
| Metadata LogRecMetadata |
| Value []byte |
| } |
| |
| func (LogRec) __VDLReflect(struct { |
| Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.LogRec"` |
| }) { |
| } |
| |
| // GroupId is a globally unique syncgroup ID. |
| // TODO(hpucha): Make this a string since now the syncgroup id is an object id. |
| type GroupId uint64 |
| |
| func (GroupId) __VDLReflect(struct { |
| Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.GroupId"` |
| }) { |
| } |
| |
| // Possible states for a syncgroup. |
| type SyncgroupStatus int |
| |
| const ( |
| SyncgroupStatusPublishPending SyncgroupStatus = iota |
| SyncgroupStatusPublishRejected |
| SyncgroupStatusRunning |
| ) |
| |
| // SyncgroupStatusAll holds all labels for SyncgroupStatus. |
| var SyncgroupStatusAll = [...]SyncgroupStatus{SyncgroupStatusPublishPending, SyncgroupStatusPublishRejected, SyncgroupStatusRunning} |
| |
| // SyncgroupStatusFromString creates a SyncgroupStatus from a string label. |
| func SyncgroupStatusFromString(label string) (x SyncgroupStatus, err error) { |
| err = x.Set(label) |
| return |
| } |
| |
| // Set assigns label to x. |
| func (x *SyncgroupStatus) Set(label string) error { |
| switch label { |
| case "PublishPending", "publishpending": |
| *x = SyncgroupStatusPublishPending |
| return nil |
| case "PublishRejected", "publishrejected": |
| *x = SyncgroupStatusPublishRejected |
| return nil |
| case "Running", "running": |
| *x = SyncgroupStatusRunning |
| return nil |
| } |
| *x = -1 |
| return fmt.Errorf("unknown label %q in interfaces.SyncgroupStatus", label) |
| } |
| |
| // String returns the string label of x. |
| func (x SyncgroupStatus) String() string { |
| switch x { |
| case SyncgroupStatusPublishPending: |
| return "PublishPending" |
| case SyncgroupStatusPublishRejected: |
| return "PublishRejected" |
| case SyncgroupStatusRunning: |
| return "Running" |
| } |
| return "" |
| } |
| |
| func (SyncgroupStatus) __VDLReflect(struct { |
| Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.SyncgroupStatus"` |
| Enum struct{ PublishPending, PublishRejected, Running string } |
| }) { |
| } |
| |
| // Syncgroup contains the state of a syncgroup. |
| type Syncgroup struct { |
| Id GroupId // globally unique identifier generated by Syncbase |
| Name string // globally unique Vanadium name chosen by app |
| SpecVersion string // version on syncgroup spec for concurrency control |
| Spec nosql.SyncgroupSpec // app-given specification |
| Creator string // Creator's Vanadium name |
| AppName string // Globally unique App name |
| DbName string // Database name within the App |
| Status SyncgroupStatus // Status of the syncgroup |
| Joiners map[string]nosql.SyncgroupMemberInfo // map of joiners to their metadata |
| } |
| |
| func (Syncgroup) __VDLReflect(struct { |
| Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.Syncgroup"` |
| }) { |
| } |
| |
| type ( |
| // DeltaReq represents any single field of the DeltaReq union type. |
| // |
| // DeltaReq contains a request to sync either data or syncgroup metadata for a |
| // Database. |
| DeltaReq interface { |
| // Index returns the field index. |
| Index() int |
| // Interface returns the field value as an interface. |
| Interface() interface{} |
| // Name returns the field name. |
| Name() string |
| // __VDLReflect describes the DeltaReq union type. |
| __VDLReflect(__DeltaReqReflect) |
| } |
| // DeltaReqSgs represents field Sgs of the DeltaReq union type. |
| DeltaReqSgs struct{ Value SgDeltaReq } |
| // DeltaReqData represents field Data of the DeltaReq union type. |
| DeltaReqData struct{ Value DataDeltaReq } |
| // __DeltaReqReflect describes the DeltaReq union type. |
| __DeltaReqReflect struct { |
| Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.DeltaReq"` |
| Type DeltaReq |
| Union struct { |
| Sgs DeltaReqSgs |
| Data DeltaReqData |
| } |
| } |
| ) |
| |
| func (x DeltaReqSgs) Index() int { return 0 } |
| func (x DeltaReqSgs) Interface() interface{} { return x.Value } |
| func (x DeltaReqSgs) Name() string { return "Sgs" } |
| func (x DeltaReqSgs) __VDLReflect(__DeltaReqReflect) {} |
| |
| func (x DeltaReqData) Index() int { return 1 } |
| func (x DeltaReqData) Interface() interface{} { return x.Value } |
| func (x DeltaReqData) Name() string { return "Data" } |
| func (x DeltaReqData) __VDLReflect(__DeltaReqReflect) {} |
| |
| // DataDeltaReq contains the initiator's genvector and the set of syncgroups it |
| // is interested in within a Database (specified by the AppName/DbName) when |
| // requesting deltas for that Database. |
| type DataDeltaReq struct { |
| AppName string |
| DbName string |
| SgIds map[GroupId]struct{} |
| InitVec GenVector |
| } |
| |
| func (DataDeltaReq) __VDLReflect(struct { |
| Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.DataDeltaReq"` |
| }) { |
| } |
| |
| // SgDeltaReq contains the initiator's genvector for the syncgroups it is |
| // interested in within a Database (specified by the AppName/DbName) when |
| // requesting deltas for those syncgroups. |
| type SgDeltaReq struct { |
| AppName string |
| DbName string |
| InitVec GenVector // Contains a genvector per syncgroup. |
| } |
| |
| func (SgDeltaReq) __VDLReflect(struct { |
| Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.SgDeltaReq"` |
| }) { |
| } |
| |
| type ( |
| // DeltaResp represents any single field of the DeltaResp union type. |
| // |
| // DeltaResp contains the responder's genvector or the missing log records |
| // returned in response to an initiator's request for deltas for a Database. |
| DeltaResp interface { |
| // Index returns the field index. |
| Index() int |
| // Interface returns the field value as an interface. |
| Interface() interface{} |
| // Name returns the field name. |
| Name() string |
| // __VDLReflect describes the DeltaResp union type. |
| __VDLReflect(__DeltaRespReflect) |
| } |
| // DeltaRespRec represents field Rec of the DeltaResp union type. |
| DeltaRespRec struct{ Value LogRec } |
| // DeltaRespRespVec represents field RespVec of the DeltaResp union type. |
| DeltaRespRespVec struct{ Value GenVector } |
| // __DeltaRespReflect describes the DeltaResp union type. |
| __DeltaRespReflect struct { |
| Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.DeltaResp"` |
| Type DeltaResp |
| Union struct { |
| Rec DeltaRespRec |
| RespVec DeltaRespRespVec |
| } |
| } |
| ) |
| |
| func (x DeltaRespRec) Index() int { return 0 } |
| func (x DeltaRespRec) Interface() interface{} { return x.Value } |
| func (x DeltaRespRec) Name() string { return "Rec" } |
| func (x DeltaRespRec) __VDLReflect(__DeltaRespReflect) {} |
| |
| func (x DeltaRespRespVec) Index() int { return 1 } |
| func (x DeltaRespRespVec) Interface() interface{} { return x.Value } |
| func (x DeltaRespRespVec) Name() string { return "RespVec" } |
| func (x DeltaRespRespVec) __VDLReflect(__DeltaRespReflect) {} |
| |
| // ChunkHash contains the hash of a chunk that is part of a blob's recipe. |
| type ChunkHash struct { |
| Hash []byte |
| } |
| |
| func (ChunkHash) __VDLReflect(struct { |
| Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.ChunkHash"` |
| }) { |
| } |
| |
| // ChunkData contains the data of a chunk. |
| type ChunkData struct { |
| Data []byte |
| } |
| |
| func (ChunkData) __VDLReflect(struct { |
| Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.ChunkData"` |
| }) { |
| } |
| |
| // TimeReq contains the send timestamp from the requester. |
| type TimeReq struct { |
| SendTs time.Time |
| } |
| |
| func (TimeReq) __VDLReflect(struct { |
| Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.TimeReq"` |
| }) { |
| } |
| |
| // TimeResp contains timestamps needed by the requester to correctly estimate |
| // the difference between the two clocks along with clock metadata required |
| // by the requester to decide which clock is more accurate. |
| type TimeResp struct { |
| // The send timestamp received in TimeReq from the originator. |
| OrigTs time.Time |
| // Time when the request was received. |
| RecvTs time.Time |
| // Time when the response was sent. |
| SendTs time.Time |
| // Timestamp received from NTP during last NTP sync. The last NTP sync could |
| // be done either by this device or some other device that this device |
| // synced its clock with. |
| LastNtpTs *time.Time |
| // Number of reboots since last NTP sync. |
| NumReboots uint16 |
| // Number of hops between this device and the device that did the last |
| // NTP sync. |
| NumHops uint16 |
| } |
| |
| func (TimeResp) __VDLReflect(struct { |
| Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.TimeResp"` |
| }) { |
| } |
| |
| func init() { |
| vdl.Register((*PrefixGenVector)(nil)) |
| vdl.Register((*GenVector)(nil)) |
| vdl.Register((*LogRecMetadata)(nil)) |
| vdl.Register((*LogRec)(nil)) |
| vdl.Register((*GroupId)(nil)) |
| vdl.Register((*SyncgroupStatus)(nil)) |
| vdl.Register((*Syncgroup)(nil)) |
| vdl.Register((*DeltaReq)(nil)) |
| vdl.Register((*DataDeltaReq)(nil)) |
| vdl.Register((*SgDeltaReq)(nil)) |
| vdl.Register((*DeltaResp)(nil)) |
| vdl.Register((*ChunkHash)(nil)) |
| vdl.Register((*ChunkData)(nil)) |
| vdl.Register((*TimeReq)(nil)) |
| vdl.Register((*TimeResp)(nil)) |
| } |
| |
| const NoGroupId = GroupId(0) |
| |
| // NodeRec type log record adds a new node in the dag. |
| const NodeRec = byte(0) |
| |
| // LinkRec type log record adds a new link in the dag. Link records are |
| // added when a conflict is resolved by picking the local or the remote |
| // version as the resolution of a conflict, instead of creating a new |
| // version. |
| const LinkRec = byte(1) |