document

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2020 License: Apache-2.0 Imports: 9 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// Detached means that the document is not attached to the client.
	// The actor of the ticket is created without being assigned.
	Detached stateType = iota

	// Attached means that this document is attached to the client.
	// The actor of the ticket is created with being assigned by the client.
	Attached
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	// contains filtered or unexported fields
}

Document represents a document accessible to the user.

How document works: The operations are generated by the proxy while executing user's command on the clone. Then the operations will apply the changes into the base json root. This is to protect the base json from errors that may occur while user edit the document.

func FromSnapshot

func FromSnapshot(
	collection string,
	document string,
	serverSeq uint64,
	snapshot []byte,
) (*Document, error)

FromSnapshot creates a new instance of Document with the snapshot.

func New

func New(collection, document string) *Document

New creates a new instance of Document.

func (*Document) Actor

func (d *Document) Actor() *time.ActorID

Actor sets actor.

func (*Document) ApplyChangePack

func (d *Document) ApplyChangePack(pack *change.Pack) error

ApplyChangePack applies the given change pack into this document.

func (*Document) Checkpoint

func (d *Document) Checkpoint() *checkpoint.Checkpoint

Checkpoint returns the checkpoint of this document.

func (*Document) CreateChangePack

func (d *Document) CreateChangePack() *change.Pack

CreateChangePack creates pack of the local changes to send to the server.

func (*Document) GarbageCollect

func (d *Document) GarbageCollect(ticket *time.Ticket) int

GarbageCollect purge elements that were removed before the given time.

func (*Document) GarbageLen

func (d *Document) GarbageLen() int

GarbageLen returns the count of removed elements.

func (*Document) HasLocalChanges

func (d *Document) HasLocalChanges() bool

HasLocalChanges returns whether this document has local changes or not.

func (*Document) IsAttached

func (d *Document) IsAttached() bool

IsAttached returns the whether this document is attached or not.

func (*Document) Key

func (d *Document) Key() *key.Key

Key returns the key of this document.

func (*Document) Marshal

func (d *Document) Marshal() string

Marshal returns the JSON encoding of this document.

func (*Document) RootObject

func (d *Document) RootObject() *json.Object

RootObject returns the root object.

func (*Document) SetActor

func (d *Document) SetActor(actor *time.ActorID)

SetActor sets actor into this document. This is also applied in the local changes the document has.

func (*Document) Update

func (d *Document) Update(
	updater func(root *proxy.ObjectProxy) error,
	msgAndArgs ...interface{},
) error

Update executes the given updater to update this document.

func (*Document) UpdateState

func (d *Document) UpdateState(state stateType)

UpdateState updates the state of this document.

type InternalDocument

type InternalDocument struct {
	// contains filtered or unexported fields
}

InternalDocument represents a document in MongoDB and contains logical clocks.

func NewInternalDocument

func NewInternalDocument(collection, document string) *InternalDocument

NewInternalDocument creates a new instance of InternalDocument.

func NewInternalDocumentFromSnapshot

func NewInternalDocumentFromSnapshot(
	collection string,
	document string,
	serverSeq uint64,
	snapshot []byte,
) (*InternalDocument, error)

NewInternalDocumentFromSnapshot creates a new instance of InternalDocument with the snapshot.

func (*InternalDocument) Actor

func (d *InternalDocument) Actor() *time.ActorID

Actor sets actor.

func (*InternalDocument) ApplyChangePack

func (d *InternalDocument) ApplyChangePack(pack *change.Pack) error

ApplyChangePack applies the given change pack into this document.

func (*InternalDocument) Checkpoint

func (d *InternalDocument) Checkpoint() *checkpoint.Checkpoint

Checkpoint returns the checkpoint of this document.

func (*InternalDocument) CreateChangePack

func (d *InternalDocument) CreateChangePack() *change.Pack

CreateChangePack creates pack of the local changes to send to the server.

func (*InternalDocument) GarbageCollect

func (d *InternalDocument) GarbageCollect(ticket *time.Ticket) int

GarbageCollect purge elements that were removed before the given time.

func (*InternalDocument) GarbageLen

func (d *InternalDocument) GarbageLen() int

GarbageLen returns the count of removed elements.

func (*InternalDocument) HasLocalChanges

func (d *InternalDocument) HasLocalChanges() bool

HasLocalChanges returns whether this document has local changes or not.

func (*InternalDocument) IsAttached

func (d *InternalDocument) IsAttached() bool

IsAttached returns the whether this document is attached or not.

func (*InternalDocument) Key

func (d *InternalDocument) Key() *key.Key

Key returns the key of this document.

func (*InternalDocument) Marshal

func (d *InternalDocument) Marshal() string

Marshal returns the JSON encoding of this document.

func (*InternalDocument) RootObject

func (d *InternalDocument) RootObject() *json.Object

RootObject returns the root object.

func (*InternalDocument) SetActor

func (d *InternalDocument) SetActor(actor *time.ActorID)

SetActor sets actor into this document. This is also applied in the local changes the document has.

func (*InternalDocument) UpdateState

func (d *InternalDocument) UpdateState(state stateType)

UpdateState updates the state of this document.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL