Documentation ¶
Index ¶
- Constants
- Variables
- type Change
- func (c *Change) ClientSeq() uint32
- func (c *Change) Execute(root *json.Root) error
- func (c *Change) ID() ID
- func (c *Change) Message() string
- func (c *Change) Operations() []operations.Operation
- func (c *Change) ServerSeq() int64
- func (c *Change) SetActor(actor *time.ActorID)
- func (c *Change) SetServerSeq(serverSeq int64)
- type Checkpoint
- func (cp *Checkpoint) Equals(other Checkpoint) bool
- func (cp Checkpoint) Forward(other Checkpoint) Checkpoint
- func (cp Checkpoint) IncreaseClientSeq(inc uint32) Checkpoint
- func (cp Checkpoint) NextClientSeq() Checkpoint
- func (cp Checkpoint) NextServerSeq(serverSeq int64) Checkpoint
- func (cp Checkpoint) String() string
- func (cp Checkpoint) SyncClientSeq(clientSeq uint32) Checkpoint
- type Context
- func (c *Context) HasOperations() bool
- func (c *Context) ID() ID
- func (c *Context) IssueTimeTicket() *time.Ticket
- func (c *Context) Push(op operations.Operation)
- func (c *Context) RegisterElement(elem json.Element)
- func (c *Context) RegisterRemovedElementPair(parent json.Container, deleted json.Element)
- func (c *Context) RegisterTextElementWithGarbage(textType json.TextElement)
- func (c *Context) ToChange() *Change
- type ID
- func (id ID) ActorID() *time.ActorID
- func (id ID) ClientSeq() uint32
- func (id ID) Lamport() int64
- func (id ID) NewTimeTicket(delimiter uint32) *time.Ticket
- func (id ID) Next() ID
- func (id ID) ServerSeq() int64
- func (id ID) SetActor(actor *time.ActorID) ID
- func (id ID) SetServerSeq(serverSeq int64) ID
- func (id ID) SyncLamport(otherLamport int64) ID
- type Pack
Constants ¶
const ( // InitialClientSeq is the initial sequence number of the client. InitialClientSeq = 0 // InitialServerSeq is the initial sequence number of the server. InitialServerSeq = 0 )
const (
// InitialLamport is the initial value of Lamport timestamp.
InitialLamport = 0
)
Variables ¶
var InitialCheckpoint = NewCheckpoint(InitialServerSeq, InitialClientSeq)
InitialCheckpoint is the initial value of Checkpoint.
var ( // InitialID represents the initial state ID. Usually this is used to // represent a state where nothing has been edited. InitialID = NewID(InitialClientSeq, InitialServerSeq, InitialLamport, time.InitialActorID) )
var MaxCheckpoint = NewCheckpoint(math.MaxInt64, math.MaxUint32)
MaxCheckpoint is the maximum value of Checkpoint.
Functions ¶
This section is empty.
Types ¶
type Change ¶
type Change struct {
// contains filtered or unexported fields
}
Change represents a unit of modification in the document.
func New ¶
func New(id ID, message string, operations []operations.Operation) *Change
New creates a new instance of Change.
func (*Change) Operations ¶
func (c *Change) Operations() []operations.Operation
Operations returns the operations of this change.
func (*Change) SetServerSeq ¶
SetServerSeq sets the given serverSeq.
type Checkpoint ¶ added in v0.2.2
type Checkpoint struct { // serverSeq is the sequence of the change on the server. We can find the // change with serverSeq and documentID in the server. If the change is not // stored on the server, serverSeq is 0. ServerSeq int64 // clientSeq is the sequence of the change within the client that made the // change. ClientSeq uint32 }
Checkpoint is used to determine the client received changes. It is not meant to be used to determine the logical order of changes.
func NewCheckpoint ¶ added in v0.2.2
func NewCheckpoint(serverSeq int64, clientSeq uint32) Checkpoint
NewCheckpoint creates a new instance of Checkpoint.
func (*Checkpoint) Equals ¶ added in v0.2.2
func (cp *Checkpoint) Equals(other Checkpoint) bool
Equals returns whether the given checkpoint is equal to this checkpoint or not.
func (Checkpoint) Forward ¶ added in v0.2.2
func (cp Checkpoint) Forward(other Checkpoint) Checkpoint
Forward updates the given checkpoint with those values when it is greater than the values of internal properties.
func (Checkpoint) IncreaseClientSeq ¶ added in v0.2.2
func (cp Checkpoint) IncreaseClientSeq(inc uint32) Checkpoint
IncreaseClientSeq creates a new instance with increased client sequence.
func (Checkpoint) NextClientSeq ¶ added in v0.2.2
func (cp Checkpoint) NextClientSeq() Checkpoint
NextClientSeq creates a new instance with next client sequence.
func (Checkpoint) NextServerSeq ¶ added in v0.2.2
func (cp Checkpoint) NextServerSeq(serverSeq int64) Checkpoint
NextServerSeq creates a new instance with next server sequence.
func (Checkpoint) String ¶ added in v0.2.2
func (cp Checkpoint) String() string
String returns the string of information about this checkpoint.
func (Checkpoint) SyncClientSeq ¶ added in v0.2.2
func (cp Checkpoint) SyncClientSeq(clientSeq uint32) Checkpoint
SyncClientSeq updates the given clientSeq if it is greater than the internal value.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context is used to record the context of modification when editing a document. Each time we add an operation, a new time ticket is issued. Finally, returns a Change after the modification has been completed.
func NewContext ¶
NewContext creates a new instance of Context.
func (*Context) HasOperations ¶
HasOperations returns whether this change has operations or not.
func (*Context) IssueTimeTicket ¶
IssueTimeTicket creates a time ticket to be used to create a new operation.
func (*Context) Push ¶
func (c *Context) Push(op operations.Operation)
Push pushes a new operations into context queue.
func (*Context) RegisterElement ¶
RegisterElement registers the given element to the root.
func (*Context) RegisterRemovedElementPair ¶ added in v0.1.1
RegisterRemovedElementPair registers the given element pair to hash table.
func (*Context) RegisterTextElementWithGarbage ¶ added in v0.1.11
func (c *Context) RegisterTextElementWithGarbage(textType json.TextElement)
RegisterTextElementWithGarbage register the given text element with garbage to hash table.
type ID ¶
type ID struct {
// contains filtered or unexported fields
}
ID is for identifying the Change. It is immutable.
func (ID) NewTimeTicket ¶
NewTimeTicket creates a ticket of the given delimiter.
func (ID) SetServerSeq ¶ added in v0.2.2
SetServerSeq sets server sequence of this ID.
func (ID) SyncLamport ¶
SyncLamport syncs lamport timestamp with the given ID.
type Pack ¶
type Pack struct { // DocumentKey is key of the document. DocumentKey key.Key // Checkpoint is used to determine the client received changes. Checkpoint Checkpoint // Change represents a unit of modification in the document. Changes []*Change // Snapshot is a byte array that encode the document. Snapshot []byte // MinSyncedTicket is the minimum logical time taken by clients who attach the document. // It used to collect garbage on the replica on the client. MinSyncedTicket *time.Ticket }
Pack is a unit for delivering changes in a document to the remote.
func (*Pack) ChangesLen ¶ added in v0.1.10
ChangesLen returns the size of the changes.
func (*Pack) HasChanges ¶
HasChanges returns the whether pack has changes or not.
func (*Pack) OperationsLen ¶ added in v0.1.10
OperationsLen returns the size of the operations.