Documentation ¶
Overview ¶
Package ot provides operational transformation utilities for byte text collaboration.
The code is based on, and in part compatible with https://github.com/Operational-Transformation/ot.js by Tim Baumann (MIT License).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Doc *Doc // the document Rev int // last acknowledged revision Wait Ops // pending ops or nil Buf Ops // buffered ops or nil // Send is called when a new revision can be sent to the server. Send func(rev int, ops Ops) }
Client represent a client document with synchronization mechanisms. The client has three states:
- A synchronized client sends applied ops immediately and …
- waits for an acknowledgement from the server, meanwhile buffering applied ops.
- The buffer is composed with new ops and sent immediately when the pending ack arrives.
func (*Client) Ack ¶
Ack acknowledges a pending server update and sends buffered updates if any. An error is returned if no update is pending.
type Op ¶
type Op struct { // N signifies the operation type: // > 0: Retain N bytes // < 0: Delete -N bytes // == 0: Noop or Insert string S N int S string }
Op represents a single operation.
func (*Op) MarshalJSON ¶
MarshalJSON encodes op either as json number or string.
func (*Op) UnmarshalJSON ¶
UnmarshalJSON decodes a json number or string into op.
type Ops ¶
type Ops []Op
Ops represents a sequence of operations.
func Compose ¶
Compose returns an operation sequence composed from the consecutive ops a and b. An error is returned if the composition failed.
func Transform ¶
Transform returns two operation sequences derived from the concurrent ops a and b. An error is returned if the transformation failed.