Documentation ¶
Overview ¶
Package implements differential synchronization method by N. Fraser For more info please visit: https://neil.fraser.name/writing/sync/
Index ¶
- Constants
- type DSPatch
- type GoDS
- func (gods *GoDS) AddClientConnection(key interface{})
- func (gods *GoDS) AddServerConnection(key interface{})
- func (gods *GoDS) ApplyPatch(patches []DSPatch, connId interface{}) (string, error)
- func (gods *GoDS) GetPatch(connId interface{}) ([]DSPatch, error)
- func (gods *GoDS) RemoveConnection(connId interface{})
- func (gods *GoDS) SetStorage(storage Storage) *GoDS
- type MemoryStorage
- type Storage
Constants ¶
const DOCTYPE_BACKUP = 4
Constant is backup document send to Get or Set method in storage
const DOCTYPE_DOCUMENT = 1
Constant is standard document type send to Get or Set method in storage
const DOCTYPE_SHADOW = 2
Constant is shadow type document send to Get or Set method in storage
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DSPatch ¶
type DSPatch struct { Diffs []diffmatchpatch.Patch // Slice of patches generated by diff patch match algorithm (see http://github.com/sergi/go-diff/diffmatchpatch) Version versions // This struct contains versions of patches }
Patch object, represents patch uses in Differential Synchronization Patch contains diff generated by diff algoritm and versions of documents uses in synchronization cycle
type GoDS ¶
type GoDS struct {
// contains filtered or unexported fields
}
func (*GoDS) AddClientConnection ¶
func (gods *GoDS) AddClientConnection(key interface{})
Create new client connection for GoDS object which represent client
func (*GoDS) AddServerConnection ¶
func (gods *GoDS) AddServerConnection(key interface{})
Create new server connection for GoDS object which represent server
func (*GoDS) ApplyPatch ¶
Receive patches and return patched document First method property receive array of DSPatch object generated by GetPatch method Second method property receive connection id provided in AddClientConnection or AddServerConnection methods
func (*GoDS) GetPatch ¶
Method return patch array which receive ApplyPatch method Method property receive connection id provided in AddClientConnection or AddServerConnection methods
func (*GoDS) RemoveConnection ¶
func (gods *GoDS) RemoveConnection(connId interface{})
Remove connection by id
func (*GoDS) SetStorage ¶
Set synchronization storage
type MemoryStorage ¶
type MemoryStorage struct {
// contains filtered or unexported fields
}
Default Storage interface implementation, save document to variables (arrays)
type Storage ¶
type Storage interface { // Get document from storage by id Get(docType int, connId interface{}) (string, error) // Set document to storage by id Set(docType int, connId interface{}, text string) error }
Storage interface provide methods to save and load documents created by Differential Synchronization You can create different kinds of storages for save and load from file, DB or eg. web... Storage function should return error!