operations

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package operations implements the operations that can be executed on the document.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotApplicableDataType occurs when attempting to execute an operation
	// on a data type that cannot be executed.
	ErrNotApplicableDataType = errors.New("not applicable datatype")
)

Functions

This section is empty.

Types

type Add

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

Add is an operation representing adding an element to an Array.

func NewAdd

func NewAdd(
	parentCreatedAt *time.Ticket,
	prevCreatedAt *time.Ticket,
	value crdt.Element,
	executedAt *time.Ticket,
) *Add

NewAdd creates a new instance of Add.

func (*Add) Execute

func (o *Add) Execute(root *crdt.Root) error

Execute executes this operation on the given document(`root`).

func (*Add) ExecutedAt

func (o *Add) ExecutedAt() *time.Ticket

ExecutedAt returns execution time of this operation.

func (*Add) ParentCreatedAt

func (o *Add) ParentCreatedAt() *time.Ticket

ParentCreatedAt returns the creation time of the Array.

func (*Add) PrevCreatedAt

func (o *Add) PrevCreatedAt() *time.Ticket

PrevCreatedAt returns the creation time of previous element.

func (*Add) SetActor

func (o *Add) SetActor(actorID *time.ActorID)

SetActor sets the given actor to this operation.

func (*Add) Value

func (o *Add) Value() crdt.Element

Value returns the value of this operation.

type ArraySet added in v0.5.0

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

ArraySet is an operation representing setting an element in Array.

func NewArraySet added in v0.5.0

func NewArraySet(
	parentCreatedAt *time.Ticket,
	createdAt *time.Ticket,
	value crdt.Element,
	executedAt *time.Ticket,
) *ArraySet

NewArraySet creates a new instance of ArraySet.

func (*ArraySet) CreatedAt added in v0.5.0

func (o *ArraySet) CreatedAt() *time.Ticket

CreatedAt returns the creation time of the target element.

func (*ArraySet) Execute added in v0.5.0

func (o *ArraySet) Execute(root *crdt.Root) error

Execute executes this operation on the given document(`root`).

func (*ArraySet) ExecutedAt added in v0.5.0

func (o *ArraySet) ExecutedAt() *time.Ticket

ExecutedAt returns execution time of this operation.

func (*ArraySet) ParentCreatedAt added in v0.5.0

func (o *ArraySet) ParentCreatedAt() *time.Ticket

ParentCreatedAt returns the creation time of the Array.

func (*ArraySet) SetActor added in v0.5.0

func (o *ArraySet) SetActor(actorID *time.ActorID)

SetActor sets the given actor to this operation.

func (*ArraySet) Value added in v0.5.0

func (o *ArraySet) Value() crdt.Element

Value returns the value of this operation.

type Edit

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

Edit is an operation representing editing Text. Most of the same as Edit, but with additional style properties, attributes.

func NewEdit

func NewEdit(
	parentCreatedAt *time.Ticket,
	from *crdt.RGATreeSplitNodePos,
	to *crdt.RGATreeSplitNodePos,
	maxCreatedAtMapByActor map[string]*time.Ticket,
	content string,
	attributes map[string]string,
	executedAt *time.Ticket,
) *Edit

NewEdit creates a new instance of Edit.

func (*Edit) Attributes added in v0.3.0

func (e *Edit) Attributes() map[string]string

Attributes returns the attributes of this Edit.

func (*Edit) Content

func (e *Edit) Content() string

Content returns the content of Edit.

func (*Edit) Execute

func (e *Edit) Execute(root *crdt.Root) error

Execute executes this operation on the given document(`root`).

func (*Edit) ExecutedAt

func (e *Edit) ExecutedAt() *time.Ticket

ExecutedAt returns execution time of this operation.

func (*Edit) From

func (e *Edit) From() *crdt.RGATreeSplitNodePos

From returns the start point of the editing range.

func (*Edit) MaxCreatedAtMapByActor added in v0.4.19

func (e *Edit) MaxCreatedAtMapByActor() map[string]*time.Ticket

MaxCreatedAtMapByActor returns the map that stores the latest creation time by actor for the nodes included in the editing range.

func (*Edit) ParentCreatedAt

func (e *Edit) ParentCreatedAt() *time.Ticket

ParentCreatedAt returns the creation time of the Text.

func (*Edit) SetActor

func (e *Edit) SetActor(actorID *time.ActorID)

SetActor sets the given actor to this operation.

func (*Edit) To

func (e *Edit) To() *crdt.RGATreeSplitNodePos

To returns the end point of the editing range.

type Increase

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

Increase represents an operation that increments a numeric value to Counter. Among Primitives, numeric types Integer, Long, and Double are used as values.

func NewIncrease

func NewIncrease(
	parentCreatedAt *time.Ticket,
	value crdt.Element,
	executedAt *time.Ticket,
) *Increase

NewIncrease creates the increase instance.

func (*Increase) Execute

func (o *Increase) Execute(root *crdt.Root) error

Execute executes this operation on the given document(`root`).

func (*Increase) ExecutedAt

func (o *Increase) ExecutedAt() *time.Ticket

ExecutedAt returns execution time of this operation.

func (*Increase) ParentCreatedAt

func (o *Increase) ParentCreatedAt() *time.Ticket

ParentCreatedAt returns the creation time of Counter.

func (*Increase) SetActor

func (o *Increase) SetActor(actorID *time.ActorID)

SetActor sets the given actor to this operation.

func (*Increase) Value

func (o *Increase) Value() crdt.Element

Value return the value of this operation.

type Move

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

Move is an operation representing moving an element to an Array.

func NewMove

func NewMove(
	parentCreatedAt *time.Ticket,
	prevCreatedAt *time.Ticket,
	createdAt *time.Ticket,
	executedAt *time.Ticket,
) *Move

NewMove creates a new instance of Move.

func (*Move) CreatedAt

func (o *Move) CreatedAt() *time.Ticket

CreatedAt returns the creation time of the target element.

func (*Move) Execute

func (o *Move) Execute(root *crdt.Root) error

Execute executes this operation on the given document(`root`).

func (*Move) ExecutedAt

func (o *Move) ExecutedAt() *time.Ticket

ExecutedAt returns execution time of this operation.

func (*Move) ParentCreatedAt

func (o *Move) ParentCreatedAt() *time.Ticket

ParentCreatedAt returns the creation time of the Array.

func (*Move) PrevCreatedAt

func (o *Move) PrevCreatedAt() *time.Ticket

PrevCreatedAt returns the creation time of previous element.

func (*Move) SetActor

func (o *Move) SetActor(actorID *time.ActorID)

SetActor sets the given actor to this operation.

type Operation

type Operation interface {
	// Execute executes this operation on the given document(`root`).
	Execute(root *crdt.Root) error

	// ExecutedAt returns execution time of this operation.
	ExecutedAt() *time.Ticket

	// SetActor sets the given actor to this operation.
	SetActor(id *time.ActorID)

	// ParentCreatedAt returns the creation time of the target element to
	// execute the operation.
	ParentCreatedAt() *time.Ticket
}

Operation represents an operation to be executed on a document.

type Remove

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

Remove is an operation representing removes an element from Container.

func NewRemove

func NewRemove(
	parentCreatedAt *time.Ticket,
	createdAt *time.Ticket,
	executedAt *time.Ticket,
) *Remove

NewRemove creates a new instance of Remove.

func (*Remove) CreatedAt

func (o *Remove) CreatedAt() *time.Ticket

CreatedAt returns the creation time of the target element.

func (*Remove) Execute

func (o *Remove) Execute(root *crdt.Root) error

Execute executes this operation on the given document(`root`).

func (*Remove) ExecutedAt

func (o *Remove) ExecutedAt() *time.Ticket

ExecutedAt returns execution time of this operation.

func (*Remove) ParentCreatedAt

func (o *Remove) ParentCreatedAt() *time.Ticket

ParentCreatedAt returns the creation time of the Container.

func (*Remove) SetActor

func (o *Remove) SetActor(actorID *time.ActorID)

SetActor sets the given actor to this operation.

type Set

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

Set represents an operation that stores the value corresponding to the given key in the Object.

func NewSet

func NewSet(
	parentCreatedAt *time.Ticket,
	key string,
	value crdt.Element,
	executedAt *time.Ticket,
) *Set

NewSet creates a new instance of Set.

func (*Set) Execute

func (o *Set) Execute(root *crdt.Root) error

Execute executes this operation on the given document(`root`).

func (*Set) ExecutedAt

func (o *Set) ExecutedAt() *time.Ticket

ExecutedAt returns execution time of this operation.

func (*Set) Key

func (o *Set) Key() string

Key returns the key of this operation.

func (*Set) ParentCreatedAt

func (o *Set) ParentCreatedAt() *time.Ticket

ParentCreatedAt returns the creation time of the Object.

func (*Set) SetActor

func (o *Set) SetActor(actorID *time.ActorID)

SetActor sets the given actor to this operation.

func (*Set) Value

func (o *Set) Value() crdt.Element

Value returns the value of this operation.

type Style

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

Style is an operation applies the style of the given range to Text.

func NewStyle

func NewStyle(
	parentCreatedAt *time.Ticket,
	from *crdt.RGATreeSplitNodePos,
	to *crdt.RGATreeSplitNodePos,
	maxCreatedAtMapByActor map[string]*time.Ticket,
	attributes map[string]string,
	executedAt *time.Ticket,
) *Style

NewStyle creates a new instance of Style.

func (*Style) Attributes

func (e *Style) Attributes() map[string]string

Attributes returns the attributes of this operation.

func (*Style) Execute

func (e *Style) Execute(root *crdt.Root) error

Execute executes this operation on the given document(`root`).

func (*Style) ExecutedAt

func (e *Style) ExecutedAt() *time.Ticket

ExecutedAt returns execution time of this operation.

func (*Style) From

func (e *Style) From() *crdt.RGATreeSplitNodePos

From returns the start point of the editing range.

func (*Style) MaxCreatedAtMapByActor added in v0.4.19

func (e *Style) MaxCreatedAtMapByActor() map[string]*time.Ticket

MaxCreatedAtMapByActor returns the map that stores the latest creation time by actor for the nodes included in the range to apply the style to.

func (*Style) ParentCreatedAt

func (e *Style) ParentCreatedAt() *time.Ticket

ParentCreatedAt returns the creation time of the Text.

func (*Style) SetActor

func (e *Style) SetActor(actorID *time.ActorID)

SetActor sets the given actor to this operation.

func (*Style) To

func (e *Style) To() *crdt.RGATreeSplitNodePos

To returns the end point of the editing range.

type TreeEdit added in v0.4.0

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

TreeEdit is an operation representing Tree editing.

func NewTreeEdit added in v0.4.0

func NewTreeEdit(
	parentCreatedAt *time.Ticket,
	from *crdt.TreePos,
	to *crdt.TreePos,
	contents []*crdt.TreeNode,
	splitLevel int,
	maxCreatedAtMapByActor map[string]*time.Ticket,
	executedAt *time.Ticket,
) *TreeEdit

NewTreeEdit creates a new instance of TreeEdit.

func (*TreeEdit) Contents added in v0.4.5

func (e *TreeEdit) Contents() []*crdt.TreeNode

Contents returns the content of Edit.

func (*TreeEdit) Execute added in v0.4.0

func (e *TreeEdit) Execute(root *crdt.Root) error

Execute executes this operation on the given `CRDTRoot`.

func (*TreeEdit) ExecutedAt added in v0.4.0

func (e *TreeEdit) ExecutedAt() *time.Ticket

ExecutedAt returns execution time of this operation.

func (*TreeEdit) FromPos added in v0.4.0

func (e *TreeEdit) FromPos() *crdt.TreePos

FromPos returns the start point of the editing range.

func (*TreeEdit) MaxCreatedAtMapByActor added in v0.4.19

func (e *TreeEdit) MaxCreatedAtMapByActor() map[string]*time.Ticket

MaxCreatedAtMapByActor returns the map that stores the latest creation time by actor for the nodes included in the editing range.

func (*TreeEdit) ParentCreatedAt added in v0.4.0

func (e *TreeEdit) ParentCreatedAt() *time.Ticket

ParentCreatedAt returns the creation time of the Text.

func (*TreeEdit) SetActor added in v0.4.0

func (e *TreeEdit) SetActor(actorID *time.ActorID)

SetActor sets the given actor to this operation.

func (*TreeEdit) SplitLevel added in v0.4.10

func (e *TreeEdit) SplitLevel() int

SplitLevel returns the level of the split.

func (*TreeEdit) ToPos added in v0.4.0

func (e *TreeEdit) ToPos() *crdt.TreePos

ToPos returns the end point of the editing range.

type TreeStyle added in v0.4.2

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

TreeStyle represents the style operation of the tree.

func NewTreeStyle added in v0.4.2

func NewTreeStyle(
	parentCreatedAt *time.Ticket,
	from *crdt.TreePos,
	to *crdt.TreePos,
	maxCreatedAtMapByActor map[string]*time.Ticket,
	attributes map[string]string,
	executedAt *time.Ticket,
) *TreeStyle

NewTreeStyle creates a new instance of TreeStyle.

func NewTreeStyleRemove added in v0.4.13

func NewTreeStyleRemove(
	parentCreatedAt *time.Ticket,
	from *crdt.TreePos,
	to *crdt.TreePos,
	maxCreatedAtMapByActor map[string]*time.Ticket,
	attributesToRemove []string,
	executedAt *time.Ticket,
) *TreeStyle

NewTreeStyleRemove creates a new instance of TreeStyle.

func (*TreeStyle) Attributes added in v0.4.2

func (e *TreeStyle) Attributes() map[string]string

Attributes returns the content of Style.

func (*TreeStyle) AttributesToRemove added in v0.4.13

func (e *TreeStyle) AttributesToRemove() []string

AttributesToRemove returns the content of Style.

func (*TreeStyle) Execute added in v0.4.2

func (e *TreeStyle) Execute(root *crdt.Root) error

Execute executes this operation on the given `CRDTRoot`.

func (*TreeStyle) ExecutedAt added in v0.4.2

func (e *TreeStyle) ExecutedAt() *time.Ticket

ExecutedAt returns execution time of this operation.

func (*TreeStyle) FromPos added in v0.4.2

func (e *TreeStyle) FromPos() *crdt.TreePos

FromPos returns the start point of the editing range.

func (*TreeStyle) MaxCreatedAtMapByActor added in v0.4.19

func (e *TreeStyle) MaxCreatedAtMapByActor() map[string]*time.Ticket

MaxCreatedAtMapByActor returns the map that stores the latest creation time by actor for the nodes included in the styling range.

func (*TreeStyle) ParentCreatedAt added in v0.4.2

func (e *TreeStyle) ParentCreatedAt() *time.Ticket

ParentCreatedAt returns the creation time of the Text.

func (*TreeStyle) SetActor added in v0.4.2

func (e *TreeStyle) SetActor(actorID *time.ActorID)

SetActor sets the given actor to this operation.

func (*TreeStyle) ToPos added in v0.4.2

func (e *TreeStyle) ToPos() *crdt.TreePos

ToPos returns the end point of the editing range.

Jump to

Keyboard shortcuts

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