| package vsync |
| |
| import ( |
| "veyron/services/store/raw" |
| |
| "veyron2/storage" |
| ) |
| |
| // DeviceID is the globally unique ID of a device. |
| type DeviceID string |
| // GenID is the unique ID per generation per device. |
| type GenID uint64 |
| // LSN is the log sequence number. |
| type LSN uint64 |
| // GenVector is the generation vector. |
| type GenVector map[DeviceID]GenID |
| |
| // LogRec represents a single log record that is exchanged between two |
| // peers. |
| // |
| // It contains log related metadata: DevID is the id of the |
| // device that created the log record, GNum is the ID of the |
| // generation that the log record is part of, and LSN is the log |
| // sequence number of the log record in the generation GNum. |
| // |
| // It also contains information relevant to the updates to an object |
| // in the store: ObjID is the id of the object that was |
| // updated. CurVers is the current version number of the |
| // object. Parents can contain 0, 1 or 2 parent versions that the |
| // current version is derived from, and Value is the actual value of |
| // the object mutation. |
| type LogRec struct { |
| // Log related information. |
| DevID DeviceID |
| GNum GenID |
| LSN LSN |
| // Object related information. |
| ObjID storage.ID |
| CurVers storage.Version |
| Parents []storage.Version |
| Value LogValue |
| } |
| |
| // LogValue represents an object mutation within a transaction. |
| type LogValue struct { |
| // Mutation is the store mutation representing the change in the object. |
| Mutation raw.Mutation |
| // SyncTime is the timestamp of the mutation when it arrives at the Sync server. |
| SyncTime int64 |
| // Delete indicates whether the mutation resulted in the object being |
| // deleted from the store. |
| Delete bool |
| // Continue tracks the transaction boundaries in a range of mutations. |
| // It is set to true in all transaction mutations except the last one |
| // in which it is set to false to mark the end of the transaction. |
| Continue bool |
| } |
| |
| // Sync allows a device to GetDeltas from another device. |
| type Sync interface { |
| // GetDeltas returns a device's current generation vector and all the missing log records |
| // when compared to the incoming generation vector. |
| GetDeltas(In GenVector, ClientID DeviceID) stream<_, LogRec> (Out GenVector, Err error) |
| } |