Documentation
¶
Index ¶
- Variables
- func CleanupTransactions(transactionCleanups []*Transaction, i int)
- func DecodeStateVector(input io.Reader) map[uint64]uint64
- func EQ(a *ID, b *ID) bool
- func EqualAttrs(val, value any) bool
- func FindIndexCleanStart(transaction *Transaction, strs []structs.IAbstractStruct, clock uint64) uint
- func FindIndexSS(abstractStructs []structs.IAbstractStruct, clock uint64) uint
- func GenerateNewClientId() uint64
- func GenerateRsaKey(keySize int)
- func GoAndWait(handlers ...func() error) error
- func IsParentOf(parent *types.AbstractType, child *structs.Item) bool
- func NewStackEventArgs(result *StackItem, eventType OperationType, ...) interface{}
- func RSADecrypt(cipherText []byte, fileName string) []byte
- func RSAEncrypt(plainText []byte, fileName string) []byte
- func ReadClientStructRefs(decoder IUpdateDecoder, doc *YDoc) map[uint64][]structs.IAbstractStruct
- func ReadItemContent(decoder IUpdateDecoder, info byte) (structs.IContentExt, error)
- func ReadStateVector(decoder IDSDecoder) map[uint64]uint64
- func ReadStructs(decoder IUpdateDecoder, transaction *Transaction, store *StructStore)
- func SafeAsyncExe(exeFunc func())
- func SplitSnapshotAffectedStructs(transaction *Transaction, snapshot *Snapshot)
- func TryToMergeWithLeft(strs []structs.IAbstractStruct, pos int)
- func WriteClientsStructs(encoder IUpdateEncoder, store *StructStore, _sm map[uint64]uint64)
- func WriteStateVector(encoder IDSEncoder, sv map[uint64]uint64)
- func WriteStructs(encoder IUpdateEncoder, structs []structs.IAbstractStruct, ...)
- type AbsolutePosition
- type ChangeAction
- type ChangeKey
- type ChangesCollection
- type DSDecoderV2
- type DSEncoderV2
- type DeleteItem
- type DeleteSet
- func (ds *DeleteSet) Add(client, clock, length uint64)
- func (ds *DeleteSet) CreateDeleteSetFromStructStore(ss *StructStore)
- func (ds *DeleteSet) FindIndexSS(dis []*DeleteItem, clock uint64) uint64
- func (ds *DeleteSet) IsDeleted(id *ID) bool
- func (ds *DeleteSet) IterateDeletedStructs(tr *Transaction, fun func(abstractStruct structs.IAbstractStruct) bool)
- func (ds *DeleteSet) MergeDeleteSets(dss []*DeleteSet)
- func (ds *DeleteSet) SortAndMergeDeleteSet()
- func (ds *DeleteSet) TryGcDeleteSet(store *StructStore, gcFilter func(item *structs.Item) bool)
- func (ds *DeleteSet) TryMergeDeleteSet(store *StructStore)
- func (ds *DeleteSet) Write(encoder IDSEncoder)
- type Delta
- type EventHandler
- type GCFilter
- type ID
- type IDSDecoder
- type IDSEncoder
- type IUpdateDecoder
- type IUpdateEncoder
- type NewBaseType
- type OperationType
- type PendingClientStructRef
- type RelativePosition
- type Snapshot
- type StackEventArgs
- type StackItem
- type StructStore
- func (s *StructStore) AddStruct(str structs.IAbstractStruct)
- func (s *StructStore) CleanupPendingStructs()
- func (s *StructStore) Find(id *ID) structs.IAbstractStruct
- func (s *StructStore) FollowRedone(id *ID) (structs.IAbstractStruct, uint64)
- func (s *StructStore) GetItemCleanEnd(transaction *Transaction, id *ID) structs.IAbstractStruct
- func (s *StructStore) GetItemCleanStart(transaction *Transaction, id *ID) structs.IAbstractStruct
- func (s *StructStore) GetState(c uint64) uint64
- func (s *StructStore) GetStateVector() map[uint64]uint64
- func (s *StructStore) IterateStructs(transaction *Transaction, strs []structs.IAbstractStruct, clockStart uint64, ...)
- func (s *StructStore) MergeReadStructsIntoPendingReads(clientStructsRefs map[uint64][]structs.IAbstractStruct)
- func (s *StructStore) ReadAndApplyDeleteSet(decoder IDSDecoder, transaction *Transaction)
- func (s *StructStore) ReplaceStruct(oldStruct structs.IAbstractStruct, newStruct structs.IAbstractStruct)
- func (s *StructStore) ResumeStructIntegration(transaction *Transaction)
- func (s *StructStore) TryResumePendingDeleteReaders(transaction *Transaction)
- type TransactAction
- type Transaction
- type UndoManager
- func (m *UndoManager) Clear()
- func (m *UndoManager) GetCount() uint64
- func (m *UndoManager) OnAfterTransaction(transaction *Transaction)
- func (m *UndoManager) PopStackItem(stack *list.List, operationType OperationType) (*StackItem, error)
- func (m *UndoManager) Redo() *StackItem
- func (m *UndoManager) Undo() *StackItem
- type UpdateDecoderV2
- func (u *UpdateDecoderV2) CheckDisposed() bool
- func (u *UpdateDecoderV2) ReadAny() any
- func (u *UpdateDecoderV2) ReadBuffer() []byte
- func (u *UpdateDecoderV2) ReadClient() uint64
- func (u *UpdateDecoderV2) ReadInfo() byte
- func (u *UpdateDecoderV2) ReadJson() any
- func (u *UpdateDecoderV2) ReadKey() string
- func (u *UpdateDecoderV2) ReadLeftId() *ID
- func (u *UpdateDecoderV2) ReadLength() uint64
- func (u *UpdateDecoderV2) ReadParentInfo() bool
- func (u *UpdateDecoderV2) ReadRightId() *ID
- func (u *UpdateDecoderV2) ReadString() string
- func (u *UpdateDecoderV2) ReadTypeRef() uint
- type UpdateEncoderV2
- func (u UpdateEncoderV2) WriteAny(object any)
- func (u UpdateEncoderV2) WriteBuffer(buf []byte)
- func (u UpdateEncoderV2) WriteClient(client uint64)
- func (u UpdateEncoderV2) WriteInfo(info byte)
- func (u UpdateEncoderV2) WriteJson(T any)
- func (u UpdateEncoderV2) WriteKey(key string)
- func (u UpdateEncoderV2) WriteLeftId(id *ID)
- func (u UpdateEncoderV2) WriteLength(len int)
- func (u UpdateEncoderV2) WriteParentInfo(isYKey bool)
- func (u UpdateEncoderV2) WriteRightId(id *ID)
- func (u UpdateEncoderV2) WriteString(s string)
- func (u UpdateEncoderV2) WriteTypeRef(info uint)
- func (u UpdateEncoderV2) Writer() *bufio.Writer
- type YDoc
- func (d *YDoc) ApplyUpdateV2(vector []byte, origin interface{}, local ...bool)
- func (d *YDoc) ApplyUpdateV2WithReader(reader io.Reader, origin interface{}, local ...bool)
- func (d *YDoc) CloneOptionsWithNewGuid() *YDocOptions
- func (d *YDoc) EncodeStateAsUpdateV2(encodedTargetStateVector []byte) []byte
- func (d *YDoc) EncodeStateVectorV2() []byte
- func (d *YDoc) FindRootTypeKey(Type *types.AbstractType) string
- func (d *YDoc) Get(key string) *types.AbstractType
- func (d *YDoc) Transact(tAction TransactAction, origin interface{}, local ...bool)
- func (d *YDoc) WriteStateAsUpdate(encoder IUpdateEncoder, targetStateVector map[uint64]uint64)
- type YDocOptions
- type YEvent
Constants ¶
This section is empty.
Variables ¶
var Clients = map[uint64]list.List{}
var PanicBufLen = 1024
PanicBufLen 是出异常后堆栈的打印缓冲长度
Functions ¶
func CleanupTransactions ¶
func CleanupTransactions(transactionCleanups []*Transaction, i int)
func EqualAttrs ¶
func FindIndexCleanStart ¶
func FindIndexCleanStart(transaction *Transaction, strs []structs.IAbstractStruct, clock uint64) uint
func FindIndexSS ¶
func FindIndexSS(abstractStructs []structs.IAbstractStruct, clock uint64) uint
FindIndexSS Perform a binary search on a sorted array. TODO: [quan.chen] IList<AbstractStruct> to custom class, and move this method there?
func GenerateNewClientId ¶
func GenerateNewClientId() uint64
func GoAndWait ¶
GoAndWait 提供安全并发能力,每一个函数启动一个协程处理,如果其中有一个panic或者出现异常了,整体退出,并返回第最先到达的error, panic异常会打印异常堆栈的前`PanicBufLen`个字节 如果全部执行正常则只返回nil
func IsParentOf ¶
func IsParentOf(parent *types.AbstractType, child *structs.Item) bool
func NewStackEventArgs ¶
func NewStackEventArgs(result *StackItem, eventType OperationType, parentTypes map[*types.AbstractType][]*YEvent, origin any) interface{}
func ReadClientStructRefs ¶
func ReadClientStructRefs(decoder IUpdateDecoder, doc *YDoc) map[uint64][]structs.IAbstractStruct
func ReadItemContent ¶
func ReadItemContent(decoder IUpdateDecoder, info byte) (structs.IContentExt, error)
ReadItemcontent. We use first five bits in the info flag for determining the type of the struct. 0: GC 1: Deleted content. 2: JSON content. 3: Binary content. 4: String content. 5: Embed content. (for richtext content.) 6: Format content. (a formatting marker for richtext content.) 7: Type content. 8: Any content. 9: Doc content.
func ReadStateVector ¶
func ReadStateVector(decoder IDSDecoder) map[uint64]uint64
func ReadStructs ¶
func ReadStructs(decoder IUpdateDecoder, transaction *Transaction, store *StructStore)
ReadStructs Read the next ItemId in a Decoder and fill this ItemId with the read data. <br/> This is called when data is received from a remote peer. public static void ReadStructs(IUpdateDecoder decoder, transaction *Transaction, StructStore store) { var clientStructRefs = ReadClientStructRefs(decoder, transaction.Doc); store.MergeReadStructsIntoPendingReads(clientStructRefs); store.ResumeStructIntegration(transaction); store.CleanupPendingStructs(); store.TryResumePendingDeleteReaders(transaction); }
func SafeAsyncExe ¶
func SafeAsyncExe(exeFunc func())
func SplitSnapshotAffectedStructs ¶
func SplitSnapshotAffectedStructs(transaction *Transaction, snapshot *Snapshot)
func TryToMergeWithLeft ¶
func TryToMergeWithLeft(strs []structs.IAbstractStruct, pos int)
func WriteClientsStructs ¶
func WriteClientsStructs(encoder IUpdateEncoder, store *StructStore, _sm map[uint64]uint64)
func WriteStateVector ¶
func WriteStateVector(encoder IDSEncoder, sv map[uint64]uint64)
func WriteStructs ¶
func WriteStructs(encoder IUpdateEncoder, structs []structs.IAbstractStruct, client, clock uint64)
Types ¶
type AbsolutePosition ¶
type AbsolutePosition struct {
Type structs.AbstractStruct
Index int
Assoc int
// contains filtered or unexported fields
}
func (AbsolutePosition) TryCreateFromRelativePosition ¶
func (ap AbsolutePosition) TryCreateFromRelativePosition()
type ChangeAction ¶
type ChangeAction int
const ( Add ChangeAction = 1 Update ChangeAction = 2 Delete ChangeAction = 3 )
type ChangeKey ¶
type ChangeKey struct {
Action ChangeAction
OldValue any
}
type ChangesCollection ¶
type DSDecoderV2 ¶
type DSDecoderV2 struct {
DsCurVal uint64
// contains filtered or unexported fields
}
func NewDsDecoderV2 ¶
func NewDsDecoderV2(reader io.Reader) *DSDecoderV2
func NewDsDecoderV2WithEmpty ¶
func NewDsDecoderV2WithEmpty() *DSDecoderV2
func (*DSDecoderV2) ReadDsClock ¶
func (d *DSDecoderV2) ReadDsClock() uint64
func (*DSDecoderV2) ReadDsLength ¶
func (d *DSDecoderV2) ReadDsLength() uint64
func (*DSDecoderV2) Reader ¶
func (d *DSDecoderV2) Reader() *bufio.Reader
func (*DSDecoderV2) ResetDsCurVal ¶
func (d *DSDecoderV2) ResetDsCurVal()
func (*DSDecoderV2) ToArray ¶
func (d *DSDecoderV2) ToArray() []byte
type DSEncoderV2 ¶
type DSEncoderV2 struct {
// contains filtered or unexported fields
}
func NewDsEncoderV2 ¶
func NewDsEncoderV2() *DSEncoderV2
func (DSEncoderV2) ResetDsCurVal ¶
func (v DSEncoderV2) ResetDsCurVal()
func (DSEncoderV2) RestWriter ¶
func (v DSEncoderV2) RestWriter() *bufio.ReadWriter
func (DSEncoderV2) ToArray ¶
func (v DSEncoderV2) ToArray() []byte
func (DSEncoderV2) WriteDsClock ¶
func (v DSEncoderV2) WriteDsClock(clock uint64)
func (DSEncoderV2) WriteDsLength ¶
func (v DSEncoderV2) WriteDsLength(length uint64)
type DeleteItem ¶
type DeleteSet ¶
type DeleteSet struct {
Clients map[uint64][]*DeleteItem
}
DeleteSet is a temporary object that is created when needed. - When created in a transaction, it must only be accessed after sorting and merging.
- This DeleteSet is sent to other clients.
- We do not create a DeleteSet when we send a sync message. The DeleteSet message is created directly from StructStore.
- We read a DeleteSet as a apart of sync/update message. In this case the DeleteSet is already sorted and merged.
func NewDeleteSet ¶
func NewDeleteSet(ss *StructStore) *DeleteSet
func NewDeleteSetWithArray ¶
func ReadDeleteSet ¶
func ReadDeleteSet(decoder IDSDecoder) *DeleteSet
func (*DeleteSet) CreateDeleteSetFromStructStore ¶
func (ds *DeleteSet) CreateDeleteSetFromStructStore(ss *StructStore)
func (*DeleteSet) FindIndexSS ¶
func (ds *DeleteSet) FindIndexSS(dis []*DeleteItem, clock uint64) uint64
func (*DeleteSet) IterateDeletedStructs ¶
func (ds *DeleteSet) IterateDeletedStructs(tr *Transaction, fun func(abstractStruct structs.IAbstractStruct) bool)
IterateDeletedStructs Iterate over all structs that the DeleteSet gc'd.
func (*DeleteSet) MergeDeleteSets ¶
func (*DeleteSet) SortAndMergeDeleteSet ¶
func (ds *DeleteSet) SortAndMergeDeleteSet()
func (*DeleteSet) TryGcDeleteSet ¶
func (ds *DeleteSet) TryGcDeleteSet(store *StructStore, gcFilter func(item *structs.Item) bool)
func (*DeleteSet) TryMergeDeleteSet ¶
func (ds *DeleteSet) TryMergeDeleteSet(store *StructStore)
func (*DeleteSet) Write ¶
func (ds *DeleteSet) Write(encoder IDSEncoder)
type EventHandler ¶
type EventHandler func(v any)
type IDSDecoder ¶
type IDSEncoder ¶
type IDSEncoder interface {
RestWriter() *bufio.ReadWriter
ToArray() []byte
WriteDsLength(length uint64)
WriteDsClock(clock uint64)
ResetDsCurVal()
}
type IUpdateDecoder ¶
type IUpdateEncoder ¶
type IUpdateEncoder interface {
IDSEncoder
Writer() *bufio.Writer
WriteLeftId(id *ID)
WriteRightId(id *ID)
// WriteClient NOTE: Use 'writeClient' and 'writeClock' instead of writeID if possible.
WriteClient(client uint64)
WriteInfo(info byte)
WriteString(s string)
WriteParentInfo(isYKey bool)
WriteTypeRef(info uint)
// WriteLength Write len of a struct - well suited for Opt RLE encoder.
WriteLength(len int)
WriteAny(object any)
WriteBuffer(buf []byte)
WriteKey(key string)
WriteJson(T any)
}
type NewBaseType ¶
type NewBaseType struct {
Changes *ChangesCollection
Target *types.AbstractType
CurrentTarget *types.AbstractType
Transaction *Transaction
Path []any
// contains filtered or unexported fields
}
type PendingClientStructRef ¶
type PendingClientStructRef struct {
NextReadOperation int
Refs []structs.IAbstractStruct
}
type RelativePosition ¶
type RelativePosition struct {
ItemId *ID
TypeId *ID
TName string
// A relative position is associated to a specific character.
// By default, the value is <c>>&eq; 0</c>, the relative position is associated to the character
// after the meant position.
// I.e. position <c>1</c> in <c>'ab'</c> is associated with the character <c>'b'</c>.
// If the value is <c>< 0</c>, then the relative position is associated with the character
// before the meant position.
Assoc int
}
func ReadByteRP ¶
func ReadByteRP(b []byte) *RelativePosition
func ReadRP ¶
func ReadRP(reader *bufio.Reader) *RelativePosition
type Snapshot ¶
func (*Snapshot) EncodeSnapshotV2 ¶
func (*Snapshot) RestoreDocument ¶
func (s *Snapshot) RestoreDocument(originDoc *YDoc, opts *YDocOptions) *YDoc
type StackEventArgs ¶
type StackEventArgs struct {
StackItem *StackItem
Type OperationType
ChangedParentTypes map[*types.AbstractType][]*YEvent
Origin any
}
type StackItem ¶
type StructStore ¶
type StructStore struct {
Clients map[uint64][]structs.IAbstractStruct
PendingClientStructRefs map[uint64]*PendingClientStructRef
PendingStack *list.List
PendingDeleteReaders []*DSDecoderV2
}
var Store StructStore
func (*StructStore) AddStruct ¶
func (s *StructStore) AddStruct(str structs.IAbstractStruct)
func (*StructStore) CleanupPendingStructs ¶
func (s *StructStore) CleanupPendingStructs()
func (*StructStore) Find ¶
func (s *StructStore) Find(id *ID) structs.IAbstractStruct
Find Expects that id is actually in store. This function throws or is an infinite loop otherwise.
func (*StructStore) FollowRedone ¶
func (s *StructStore) FollowRedone(id *ID) (structs.IAbstractStruct, uint64)
func (*StructStore) GetItemCleanEnd ¶
func (s *StructStore) GetItemCleanEnd(transaction *Transaction, id *ID) structs.IAbstractStruct
func (*StructStore) GetItemCleanStart ¶
func (s *StructStore) GetItemCleanStart(transaction *Transaction, id *ID) structs.IAbstractStruct
func (*StructStore) GetState ¶
func (s *StructStore) GetState(c uint64) uint64
func (*StructStore) GetStateVector ¶
func (s *StructStore) GetStateVector() map[uint64]uint64
GetStateVector Return the states as a Map[int]int Note that Clock refers to the next expected Clock id.
func (*StructStore) IterateStructs ¶
func (s *StructStore) IterateStructs(transaction *Transaction, strs []structs.IAbstractStruct, clockStart uint64, length uint64, fun func(abstractStruct structs.IAbstractStruct) bool)
func (*StructStore) MergeReadStructsIntoPendingReads ¶
func (s *StructStore) MergeReadStructsIntoPendingReads(clientStructsRefs map[uint64][]structs.IAbstractStruct)
func (*StructStore) ReadAndApplyDeleteSet ¶
func (s *StructStore) ReadAndApplyDeleteSet(decoder IDSDecoder, transaction *Transaction)
func (*StructStore) ReplaceStruct ¶
func (s *StructStore) ReplaceStruct(oldStruct structs.IAbstractStruct, newStruct structs.IAbstractStruct)
func (*StructStore) ResumeStructIntegration ¶
func (s *StructStore) ResumeStructIntegration(transaction *Transaction)
ResumeStructIntegration Resume computing structs generated by struct readers. While there is something to do, we integrate structs in this order: 1. Top element on stack, if stack is not empty. 2. Next element from current struct reader (if empty, use next struct reader). If struct causally depends on another struct (ref.missing), we put next reader of 'ref.id.client' on top of stack. At some point we find a struct that has no causal dependencies, then we start emptying the stack. It is not possible to have circles: i.e. struct1 (from client1) depends on struct2 (from client2) depends on struct3 (from client1). Therefore, the max stack size is equal to 'structReaders.length'. This method is implemented in a way so that we can resume computation if this update causally depends on another update.
func (*StructStore) TryResumePendingDeleteReaders ¶
func (s *StructStore) TryResumePendingDeleteReaders(transaction *Transaction)
type TransactAction ¶
type TransactAction func(*Transaction)
type Transaction ¶
type Transaction struct {
Doc *YDoc
BeforeState map[uint64]uint64
AfterState map[uint64]uint64
DeletedStructs map[*structs.Item]struct{}
NewTypes map[*structs.Item]struct{}
DeleteSet *DeleteSet
// Changed map[*types.AbstractType]map[string]struct{}
Changed map[any]map[string]struct{}
ChangedParentTypes map[*types.AbstractType][]*YEvent
MergeStructs []structs.IAbstractStruct
Origin any
Local bool
Meta map[string]any
SubdocsAdded map[*YDoc]struct{}
SubdocsRemoved map[*YDoc]struct{}
SubdocsLoaded map[*YDoc]struct{}
}
func NewTransaction ¶
func NewTransaction(doc *YDoc, origin interface{}, local ...bool) *Transaction
func (*Transaction) AddChangedTypeToTransaction ¶
func (t *Transaction) AddChangedTypeToTransaction(ty *types.AbstractType, parentSub string)
func (*Transaction) RedoItem ¶
func (t *Transaction) RedoItem(item *structs.Item, redoItems map[*structs.Item]struct{}) structs.IAbstractStruct
RedoItem Redoes the effect of this operation.
func (*Transaction) WriteUpdateMessageFromTransaction ¶
func (t *Transaction) WriteUpdateMessageFromTransaction(encoder IUpdateEncoder) bool
WriteUpdateMessageFromTransaction Whether the data was written.
type UndoManager ¶
type UndoManager struct {
Scope []*types.AbstractType
DeleteFilter func(*structs.Item) bool
TrackedOrigins map[any]struct{}
UndoStack *list.List
RedoStack *list.List
Undoing bool
Redoing bool
Doc *YDoc
LastChange time.Time
CaptureTimeout uint64
StackItemAdded EventHandler
StackItemPopped EventHandler
}
UndoManager Fires 'stack-item-added' event when a stack item was added to either the undo- or the redo-stack. You may store additional stack information via the metadata property on 'event.stackItem.meta' (it is a collection of metadata properties). Fires 'stack-item-popped' event when a stack item was popped from either the undo- or the redo-stack. You may restore the saved stack information from 'event.stackItem.Meta'.
func NewUndoManager ¶
func NewUndoManager(typeScopes []*types.AbstractType, captureTimeout uint64, deleteFilter func(*structs.Item) bool, trackedOrigins map[any]struct{}) *UndoManager
func (*UndoManager) Clear ¶
func (m *UndoManager) Clear()
func (*UndoManager) GetCount ¶
func (m *UndoManager) GetCount() uint64
func (*UndoManager) OnAfterTransaction ¶
func (m *UndoManager) OnAfterTransaction(transaction *Transaction)
func (*UndoManager) PopStackItem ¶
func (m *UndoManager) PopStackItem(stack *list.List, operationType OperationType) (*StackItem, error)
func (*UndoManager) Redo ¶
func (m *UndoManager) Redo() *StackItem
func (*UndoManager) Undo ¶
func (m *UndoManager) Undo() *StackItem
type UpdateDecoderV2 ¶
type UpdateDecoderV2 struct {
DSDecoderV2
Keys []string
KeyClockDecoder decoder.IntDiffOptRleDecoder
ClientDecoder decoder.UintOptRleDecoder
LeftClockDecoder decoder.IntDiffOptRleDecoder
RightClockDecoder decoder.IntDiffOptRleDecoder
InfoDecoder decoder.RleDecoder
StringDecoder decoder.StringDecoder
ParentInfoDecoder decoder.RleDecoder
TypeRefDecoder decoder.UintOptRleDecoder
LengthDecoder decoder.UintOptRleDecoder
}
func NewUpdateDecoderV2 ¶
func NewUpdateDecoderV2(reader io.Reader) *UpdateDecoderV2
func (*UpdateDecoderV2) CheckDisposed ¶
func (u *UpdateDecoderV2) CheckDisposed() bool
func (*UpdateDecoderV2) ReadAny ¶
func (u *UpdateDecoderV2) ReadAny() any
func (*UpdateDecoderV2) ReadBuffer ¶
func (u *UpdateDecoderV2) ReadBuffer() []byte
func (*UpdateDecoderV2) ReadClient ¶
func (u *UpdateDecoderV2) ReadClient() uint64
func (*UpdateDecoderV2) ReadInfo ¶
func (u *UpdateDecoderV2) ReadInfo() byte
func (*UpdateDecoderV2) ReadJson ¶
func (u *UpdateDecoderV2) ReadJson() any
func (*UpdateDecoderV2) ReadKey ¶
func (u *UpdateDecoderV2) ReadKey() string
func (*UpdateDecoderV2) ReadLeftId ¶
func (u *UpdateDecoderV2) ReadLeftId() *ID
func (*UpdateDecoderV2) ReadLength ¶
func (u *UpdateDecoderV2) ReadLength() uint64
func (*UpdateDecoderV2) ReadParentInfo ¶
func (u *UpdateDecoderV2) ReadParentInfo() bool
func (*UpdateDecoderV2) ReadRightId ¶
func (u *UpdateDecoderV2) ReadRightId() *ID
func (*UpdateDecoderV2) ReadString ¶
func (u *UpdateDecoderV2) ReadString() string
func (*UpdateDecoderV2) ReadTypeRef ¶
func (u *UpdateDecoderV2) ReadTypeRef() uint
type UpdateEncoderV2 ¶
type UpdateEncoderV2 struct {
DSEncoderV2
// contains filtered or unexported fields
}
func NewUpdateEncoderV2 ¶
func NewUpdateEncoderV2() *UpdateEncoderV2
func (UpdateEncoderV2) WriteAny ¶
func (u UpdateEncoderV2) WriteAny(object any)
func (UpdateEncoderV2) WriteBuffer ¶
func (u UpdateEncoderV2) WriteBuffer(buf []byte)
func (UpdateEncoderV2) WriteClient ¶
func (u UpdateEncoderV2) WriteClient(client uint64)
func (UpdateEncoderV2) WriteInfo ¶
func (u UpdateEncoderV2) WriteInfo(info byte)
func (UpdateEncoderV2) WriteJson ¶
func (u UpdateEncoderV2) WriteJson(T any)
func (UpdateEncoderV2) WriteKey ¶
func (u UpdateEncoderV2) WriteKey(key string)
func (UpdateEncoderV2) WriteLeftId ¶
func (u UpdateEncoderV2) WriteLeftId(id *ID)
func (UpdateEncoderV2) WriteLength ¶
func (u UpdateEncoderV2) WriteLength(len int)
func (UpdateEncoderV2) WriteParentInfo ¶
func (u UpdateEncoderV2) WriteParentInfo(isYKey bool)
func (UpdateEncoderV2) WriteRightId ¶
func (u UpdateEncoderV2) WriteRightId(id *ID)
func (UpdateEncoderV2) WriteString ¶
func (u UpdateEncoderV2) WriteString(s string)
func (UpdateEncoderV2) WriteTypeRef ¶
func (u UpdateEncoderV2) WriteTypeRef(info uint)
func (UpdateEncoderV2) Writer ¶
func (u UpdateEncoderV2) Writer() *bufio.Writer
type YDoc ¶
type YDoc struct {
GC bool
GCFilter GCFilter
Store *StructStore
Transaction *Transaction
TransactionCleanups []*Transaction
BeforeTransaction func(*Transaction)
BeforeObserverCalls func(*Transaction)
AfterTransaction func(*Transaction)
AfterTransactionCleanup func(*Transaction)
BeforeAllTransactions func()
AfterAllTransactions func([]*Transaction)
UpdateV2 func(data []byte, origin any, transaction *Transaction)
Destroyed func()
SubdocsChanged func(Loaded map[*YDoc]struct{}, Added map[*YDoc]struct{}, Removed map[*YDoc]struct{})
Subdocs map[*YDoc]struct{}
ClientId uint64
YDocOptions
ShouldLoad bool
// If this document is a subdocument - a document integrated into another document - them _item is defined.
Item *structs.Item
// contains filtered or unexported fields
}
func NewDoc ¶
func NewDoc(options *YDocOptions) *YDoc
func NewDocWithOption ¶
func NewDocWithOption(options *YDocOptions) *YDoc
func (*YDoc) ApplyUpdateV2 ¶
func (*YDoc) ApplyUpdateV2WithReader ¶
func (*YDoc) CloneOptionsWithNewGuid ¶
func (d *YDoc) CloneOptionsWithNewGuid() *YDocOptions
func (*YDoc) EncodeStateAsUpdateV2 ¶
EncodeStateAsUpdateV2 Write all the document as a single update message that can be applied on the remote document. If you specify the state of the remote client, it will only write the operations that are missing. Use 'WriteStateAsUpdate' instead if you are working with Encoder.
func (*YDoc) EncodeStateVectorV2 ¶
func (*YDoc) FindRootTypeKey ¶
func (d *YDoc) FindRootTypeKey(Type *types.AbstractType) string
func (*YDoc) Transact ¶
func (d *YDoc) Transact(tAction TransactAction, origin interface{}, local ...bool)
func (*YDoc) WriteStateAsUpdate ¶
func (d *YDoc) WriteStateAsUpdate(encoder IUpdateEncoder, targetStateVector map[uint64]uint64)
WriteStateAsUpdate Write all the document as a single update message. If you specify the satte of the remote client, it will only write the operations that are missing.
type YDocOptions ¶
func ReadYDocOptions ¶
func ReadYDocOptions(decoder IUpdateDecoder) *YDocOptions
func (*YDocOptions) Clone ¶
func (d *YDocOptions) Clone() *YDocOptions
func (YDocOptions) Write ¶
func (d YDocOptions) Write(encoder IUpdateEncoder, offset int)
type YEvent ¶
type YEvent struct {
NewBaseType
Transaction *Transaction
}
func (*YEvent) CollectChanges ¶
func (event *YEvent) CollectChanges() *ChangesCollection